问题描述
- 学生顺序表的处理,看清楚是 顺序表,只求代码和相关注释,明日要上交,急~~~
-
在一个数据文件中存放若干学生数据记录,每条记录都有如下数据项:学号,姓名,性别,成绩。 编一个程序,采用 顺序存储结构 存储这批数据,并对该数据进行排序。要求:数组前部为男同学,后部为女同学,并且男女同学都按成绩递减排序,分别计算男生合格率、女生合格率、全班的成绩平均分,并把排序后的学生数据记录及计算结果存入另一个数据文件中。
解决方案
这个很多语言很多方法都可以实现 简单点的用html做前台 php从数据库读数据 或者ASP.NET一个前端做表一个后台从数据库读数据
以下为ASP.NET前台 html的话就用table tr td
<table align="center" style="background-color: #99ccff">
<tr>
<td style="width: 456px; height: 40px; text-align: center">
<strong><span style="color: #ff00cc; font-family: 仿宋_GB2312; font-size: 14pt;">成绩表</span></strong></td>
</tr>
<tr>
<td style="width: 456px; height: 23px;">
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
BackColor="LightGoldenrodYellow" BorderColor="Tan" BorderWidth="1px" CellPadding="2"
Font-Bold="True" Font-Size="10pt" ForeColor="Black" GridLines="None" OnPageIndexChanging="GridView1_PageIndexChanging"
Width="450px" Height="5px">
<FooterStyle BackColor="Tan" />
<Columns>
<asp:BoundField DataField="sno" HeaderText="学号">
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="sname" HeaderText="姓名">
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="ssex" HeaderText="性别">
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="degree" HeaderText="分数">
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
</Columns>
<SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
<PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
<HeaderStyle BackColor="Tan" Font-Bold="True" />
<AlternatingRowStyle BackColor="PaleGoldenrod" />
</asp:GridView>
</td>
</tr>
</table>
你要的排序主要是依赖数据库操作 写好SQL语句就行
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
string mysql = "SELECT * FROM score WHERE sno='" + Session["uno"] + "'";
myds = mydb.ExecuteQuery(mysql, "score");
if (myds.Tables["score"].Rows.Count > 0){
GridView1.DataSource = myds.Tables["score"];
GridView1.DataBind();
}
"SELECT * FROM score WHERE sno='" + Session["uno"] + "'";
这是根据学号排序 按你的需要可以排两个条件 男生为1 女生为0的话 再加上成绩递减 就可以男上女下成绩从高到低
计算合格率,平均分就是 每个分数的变量加起来除以与之对应的总值的变量 输出百分比和整型
时间: 2024-08-24 16:37:04