| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 459 人关注过本帖
标题:求指导,求帮助!!!
只看楼主 加入收藏
xueminglie
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2012-2-27
收藏
 问题点数:0 回复次数:2 
求指导,求帮助!!!
1.现有一个班级,50人,共学习三门课程,设计一个学生成绩管理程序,要求如下:

(1)           完成三门课程及录入;或单门课程录入、或同时录入三门课。

(2)           完成成绩统计和排序:按单科分段统计和排序、平均分分段统计和排序;.

(3)           完成成绩输出:按单科输出、输出所有成绩、按平均分由高到低输出..

搜索更多相关主题的帖子: 统计 录入 管理程序 课程 三门 
2012-05-14 22:04
xueminglie
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2012-2-27
收藏
得分:0 
终于自己编好了,欢迎各位指导!!
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define CH  10                  // 最大字符
#define N   50                  // 学生的最大个数

typedef struct student
                                 //学生的结构体
{
    char  name[CH];               // 姓名
    char  no[CH];                 //学号
    float chinese;                //语文
    float math;                   //数学      
    float english;                //英语      
    float average;                //平均分数
    float total;                  //总分数
}student;

student   s[N];                  //学生数组
int   num;                       //学生个数


/*   欢迎界面   */
void welcome()
{   printf("\n\n\n\n\n");
    printf("\t\t ╭════════成绩管理系统════════╮ \n");
    printf("\t\t║                                              ║\n");
    printf("\t\t║                                              ║\n");
    printf("\t\t║           欢迎使用该成绩管理系统             ║\n");
    printf("\t\t║                                              ║\n");
    printf("\t\t║                 作者:薛明列                 ║\n");
    printf("\t\t║                                              ║\n");
    printf("\t\t║               按任意键继续……               ║\n");
    printf("\t\t║                                              ║\n");
    printf("\t\t║                                              ║\n");
    printf("\t\t╰═══════════════════════╯\n");
    getchar();
}
/*   菜单   */
void meun()
{
 system("cls");                                                   
 printf("\n\n\n\n\n");
 printf("\t\t ╭════════成绩管理系统════════╮ \n");
 printf("\t\t║                        --五邑大学专版        ║\n");
 printf("\t\t║          学 生 成 绩 管 理 系 统             ║\n");
 printf("\t\t║                   主菜单                     ║\n");
 printf("\t\t║              1. 录入学生成绩                 ║\n");
 printf("\t\t║              2. 删除学生成绩                 ║\n");
 printf("\t\t║              3. 修改学生成绩                 ║\n");
 printf("\t\t║              4. 查询学生成绩                 ║\n");
 printf("\t\t║              5. 单科分段统计                 ║\n");
 printf("\t\t║              6. 单科排名输出                 ║\n");
 printf("\t\t║              7. 总分排名输出                 ║\n");
 printf("\t\t║              8. 学号排名输出                 ║\n");
 printf("\t\t║              9. 退出系统                     ║\n");
 printf("\t\t║               作者:薛明列                   ║\n");
 printf("\t\t╰═══════════════════════╯\n");
 printf("\n\n\n\t\t             请选择菜单选项(1-9):");
}

/*   子菜单1   */
void meun1()
{
 system("cls");                                                   
 printf("\n\n\n\n\n");
 printf("\t\t ╭════════成绩管理系统════════╮ \n");
 printf("\t\t║                        --五邑大学专版        ║\n");
 printf("\t\t║          学 生 成 绩 管 理 系 统             ║\n");         
 printf("\t\t║                   子菜单                     ║\n");
 printf("\t\t║            1. 按语文成绩分段统计             ║\n");
 printf("\t\t║            2. 按数学成绩分段统计             ║\n");
 printf("\t\t║            3. 按英语成绩分段统计             ║\n");
 printf("\t\t║            4. 返回主菜单                     ║\n");
 printf("\t\t║               作者:薛明列                   ║\n");
 printf("\t\t╰═══════════════════════╯\n");
 printf("\n\n\n\t\t               请选择子菜单选项(1-4):");
}
/*   子菜单2   */
void meun2()
{
 system("cls");                                                   
 printf("\n\n\n\n\n");
 printf("\t\t ╭════════成绩管理系统════════╮ \n");
 printf("\t\t║                        --五邑大学专版        ║\n");
 printf("\t\t║          学 生 成 绩 管 理 系 统             ║\n");         
 printf("\t\t║                   子菜单                     ║\n");
 printf("\t\t║            1. 按语文成绩排名                 ║\n");
 printf("\t\t║            2. 按数学成绩排名                 ║\n");
 printf("\t\t║            3. 按英语成绩排名                 ║\n");
 printf("\t\t║            4. 返回主菜单                     ║\n");
 printf("\t\t║               作者:薛明列                   ║\n");
 printf("\t\t╰═══════════════════════╯\n");
 printf("\n\n\n\t\t               请选择子菜单选项(1-4):");
}


void Add()                                                           //录入学生成绩
{
    int i=num;
    printf("请输入学号:");
    scanf("%s",s[i].no);
    printf("请输入姓名:");
    scanf("%s",s[i].name);
    printf("请输入语文:");
    scanf("%f",&s[i].chinese);
    while(s[i].chinese<0||s[i].chinese>100)
    {
        printf("你输入的语文成绩不符合实际情况,请重新输入!\n");
        printf("请输入语文:");
        scanf("%f",&s[i].chinese);
    }
    printf("请输入数学:");
    scanf("%f",&s[i].math);
    while(s[i].math<0||s[i].math>100)
    {
        printf("你输入的数学成绩不符合实际情况,请重新输入!\n");
        printf("请输入数学:");
        scanf("%f",&s[i].math);
    }
    printf("请输入英语:");
    scanf("%f",&s[i].english);
    while(s[i].english<0||s[i].english>100)
    {
        printf("你输入的英语成绩不符合实际情况,请重新输入!\n");
        printf("请输入英语:");
        scanf("%f",&s[i].english);
    }
    printf("\n");
    s[i].total=s[i].chinese+s[i].math+s[i].english;               //计算出总分数
    s[i].average=s[i].total/3;                                    //计算出平均分
    num++;
}



void Delete()                                                    //删除学生成绩
{
    int i=0,j=0;
    char  no[CH];                                                  //学号
    printf("请输入你要删除的学生学号:");
    scanf("%s",no);
    printf("\n\n");
    for(i=0;i<num;i++)                                            //先找到该学号对应的序号
    if(strcmp(s[i].no,no)==0)
    {   printf("删除成功!\n\n");
        for(j=i;j<num-1;j++)
            s[j]=s[j+1];
        num--;                                                       //数量减少 1
        return;
    }
    printf("\n\n\n");
    printf("如果上面没有结果,则没有这个学号!\n\n");
 }


void modify()                                                       //修改学生成绩
{
    int i=0;
    char  no[CH];                                                     //学号
    printf("请输入你要修改的学生学号:");
    scanf("%s",no);
    printf("\n\n");
    for(i=0;i<num;i++)                                                //先找到该学号对应的序号
    if(strcmp(s[i].no,no)==0)
    {
        printf("请输入学号:");
        scanf("%s",s[i].no);
        printf("请输入姓名:");
        scanf("%s",s[i].name);
        printf("请输入语文:");
        scanf("%f",&s[i].chinese);
        printf("请输入数学:");
        scanf("%f",&s[i].math);
        printf("请输入英语:");
        scanf("%f",&s[i].english);
        s[i].total=s[i].chinese+s[i].math+s[i].english;             //计算出总分数
        s[i].average=s[i].total/3;                                  //计算出平均分
        printf("\n\n");
        return;
    }
    printf("\n\n\n");
    printf("如果上面没有结果,则没有这个学号!\n\n");
 }

 


void search()                                                         //查询学生成绩
{
    int i=0;
    char  no[CH];                                                       //学号
    printf("请输入你要查询的学生学号:");
    scanf("%s",no);
    printf("\n\n");
    for(i=0;i<num;i++)                                                //先找到该学号对应的序号
        if(strcmp(s[i].no,no)==0)
        {
            printf("  学号      姓名      语文       数学      英语      总分数      平均分\n");
            printf("   %s        %s       %.2f       %.2f      %.2f       %.2f        %.2f\n",s[i].no,s[i].name,s[i].chinese,s[i].math,s[i].english,s[i].total,s[i].average);
        }
        printf("\n\n\n");
        printf("如果上面没有结果,则没有这个学号!\n\n");
}



void chinese ()                                                    //按语文成绩分段统计                              
{
    int i=0;
    int verygood,good,common,pass,bad;
    verygood=good=common=pass=bad=0;
    float sum1=0,average1=0;
    printf("课程名称:语文\n");
    printf("------------------------------\n");
    printf("学号       姓名         成绩\n");
    printf("------------------------------\n");
    for (i=0;i<num;i++)
    {
        printf("%s         %s           %.2f\n",s[i].no,s[i].name,s[i].chinese);
        sum1=sum1+s[i].chinese;
        if (s[i].chinese>90)
        {
            verygood++;
        }
        else
        {
            if (s[i].chinese>80)
            {
                good++;
            }
            else
            {
                if (s[i].chinese>60)
                {
                    common++;
                }
                else
                {
                    if(s[i].chinese>60)
                    {
                        pass++;
                    }
                    else
                    {
                        bad++;
                    }
                }
            }
        }
    }
    printf("------------------------------\n");
    printf("全班语文成绩统计:\n\n平均分:%.2f\n\n",sum1*1.0/num);
    printf("------------------------------\n\n\n");
    printf("   等级          人数   所占比例\n");
    printf("90~100分(优秀)  %d       %.2f %%\n",verygood,verygood*100.0/num);
    printf("80~89分(良)     %d       %.2f %%\n",good,good*100.0/num);
    printf("70~79分(中)     %d       %.2f %%\n",common,common*100.0/num);
    printf("60~69分(及格)   %d       %.2f %%\n",pass,pass*100.0/num);
    printf("0~59分(不及格)  %d       %.2f %%\n\n\n",bad,bad*100.0/num);
}


void math ()                                                    //按数学成绩分段统计                              
{
    int i=0;
    int verygood,good,common,pass,bad;
    verygood=good=common=pass=bad=0;
    float sum2=0,average2=0;
    printf("课程名称:数学\n");
    printf("------------------------------\n");
    printf("学号        姓名         成绩\n");
    printf("------------------------------\n");
    for (i=0;i<num;i++)
    {
        printf("%s          %s           %.2f\n",s[i].no,s[i].name,s[i].math);
        sum2=sum2+s[i].math;
        if (s[i].math>90)
        {
            verygood++;
        }
        else
        {
            if (s[i].math>80)
            {
                good++;
            }
            else
            {
                if (s[i].math>60)
                {
                    common++;
                }
                else
                {
                    if(s[i].math>60)
                    {
                        pass++;
                    }
                    else
                    {
                        bad++;
                    }
                }
            }
        }
    }
    printf("------------------------------\n");
    printf("全班数学成绩统计:\n\n平均分:%.2f\n\n",sum2*1.0/num);
    printf("------------------------------\n\n\n");
    printf("   等级          人数   所占比例\n");
    printf("90~100分(优秀)  %d      %.2f %%\n",verygood,verygood*100.0/num);
    printf("80~89分(良)     %d      %.2f %%\n",good,good*100.0/num);
    printf("70~79分(中)     %d      %.2f %%\n",common,common*100.0/num);
    printf("60~69分(及格)   %d      %.2f %%\n",pass,pass*100.0/num);
    printf("0~59分(不及格)  %d      %.2f %%\n\n\n",bad,bad*100.0/num);
}

 

void english ()                                                    //按英语成绩分段统计                              
{
    int i=0;
    int verygood,good,common,pass,bad;
    verygood=good=common=pass=bad=0;
    float sum3=0,average3=0;
    printf("课程名称:英语\n");
    printf("------------------------------\n");
    printf(" 学号        姓名         成绩\n");
    printf("------------------------------\n");
    for (i=0;i<num;i++)
    {
        printf(" %s          %s           %.2f\n",s[i].no,s[i].name,s[i].english);
        sum3=sum3+s[i].english;
        if (s[i].english>90)
        {
            verygood++;
        }
        else
        {
            if (s[i].english>80)
            {
                good++;
            }
            else
            {
                if (s[i].english>60)
                {
                    common++;
                }
                else
                {
                    if(s[i].english>60)
                    {
                        pass++;
                    }
                    else
                    {
                        bad++;
                    }
                }
            }
        }
    }
    printf("------------------------------\n");
    printf("全班英语成绩统计:\n\n平均分:%.2f\n\n",sum3*1.0/num);
    printf("------------------------------\n\n\n");
    printf("   等级          人数   所占比例\n");
    printf("90~100分(优秀)  %d       %.2f %%\n",verygood,verygood*100.0/num);
    printf("80~89分(良)     %d       %.2f %%\n",good,good*100.0/num);
    printf("70~79分(中)     %d       %.2f %%\n",common,common*100.0/num);
    printf("60~69分(及格)   %d       %.2f %%\n",pass,pass*100.0/num);
    printf("0~59分(不及格)  %d       %.2f %%\n\n\n",bad,bad*100.0/num);
}



void chinese_Sort()                                          //按语文成绩排名
{
    int i=0,j=0;
    student  m;                                                //用于排序交换的临时变量
    student  s2[N];                                            //学生数组,用来排序的临时数组
    for(i=0;i<num;i++)
        s2[i]=s[i];
    for(i=0;i<num;i++)
        for(j=i+1;j<num;j++)
            if(s2[i].chinese<s2[j].chinese)
            {
                m=s2[i];
                s2[i]=s2[j];
                s2[j]=m;
            }
            printf("\t按语文成绩排名\n");
            printf("------------------------------\n");
            printf("    学号      姓名      语文          \n");
            for(i=0;i<num;i++)
            printf("     %s        %s       %.2f     \n",s2[i].no,s2[i].name,s2[i].chinese);
            printf("------------------------------\n");
            printf("\n\n\n");
}



void math_Sort()                                           //按数学成绩排名
{
    int i=0,j=0;
    student  n;                                              //用于排序交换的临时变量
    student  s3[N];                                          //学生数组,用来排序的临时数组
    for(i=0;i<num;i++)
        s3[i]=s[i];
    for(i=0;i<num;i++)
        for(j=i+1;j<num;j++)
            if(s3[i].math<s3[j].math)
            {
                n=s3[i];
                s3[i]=s3[j];
                s3[j]=n;
            }
            printf("\t按数学成绩排名\n");
            printf("------------------------------\n");
            printf("    学号      姓名      数学          \n");
            for(i=0;i<num;i++)
            printf("    %s        %s        %.2f     \n",s3[i].no,s3[i].name,s3[i].math);
            printf("------------------------------\n");
            printf("\n\n\n");
}



void english_Sort()                                           //按英语成绩排名
{
    int i=0,j=0;
    student  k;                                              //用于排序交换的临时变量
    student  s4[N];                                          //学生数组,用来排序的临时数组
    for(i=0;i<num;i++)
        s4[i]=s[i];
    for(i=0;i<num;i++)
        for(j=i+1;j<num;j++)
            if(s4[i].english<s4[j].english)
            {
                k=s4[i];
                s4[i]=s4[j];
                s4[j]=k;
            }
            printf("\t按英语成绩排名\n");
            printf("------------------------------\n");
            printf("    学号      姓名      英语          \n");
            for(i=0;i<num;i++)
            printf("    %s        %s        %.2f    \n",s4[i].no,s4[i].name,s4[i].english);
            printf("------------------------------\n");
            printf("\n\n\n");
}



void total_Sort()                                          // 总分成绩排名
{
    int i=0,j=0;
    student  t;                                              //用于排序交换的临时变量
    student  s1[N];                                          //学生数组,用来排序的临时数组
    for(i=0;i<num;i++)
        s1[i]=s[i];
    for(i=0;i<num;i++)
        for(j=i+1;j<num;j++)
            if(s1[i].average<s1[j].average)
            {
                t=s1[i];
                s1[i]=s1[j];
                s1[j]=t;
            }
            printf("\t\t\t\t按学生总分排名\n");
            printf("----------------------------------------------------------------------------\n");
            printf("       学号      姓名      语文       数学      英语      总分数      平均分\n");
            for(i=0;i<num;i++)
            printf("        %s        %s       %.2f       %.2f      %.2f      %.2f       %.2f\n",s1[i].no,s1[i].name,s1[i].chinese,s1[i].math,s1[i].english,s1[i].total,s1[i].average);
            printf("----------------------------------------------------------------------------\n");
            printf("\n\n\n");
}

 
void no_Sort()                                              // 学号排名
{
    int i=0,j=0;
    student  t;                                              //用于排序交换的临时变量
    student  s0[N];                                          //学生数组,用来排序的临时数组
    for(i=0;i<num;i++)
        s0[i]=s[i];
    for(i=0;i<num;i++)
        for(j=i+1;j<num;j++)
            if(s0[i].no>s0[j].no)
            {
                t=s0[i];
                s0[i]=s0[j];
                s0[j]=t;
            }
            printf("\t\t\t\t按学生学号排名\n\n");
            printf("----------------------------------------------------------------------------\n");
            printf("       学号      姓名      语文       数学      英语      总分数      平均分\n");
            for(i=0;i<num;i++)
            printf("       %s         %s       %.2f       %.2f      %.2f      %.2f       %.2f\n",s0[i].no,s0[i].name,s0[i].chinese,s0[i].math,s0[i].english,s0[i].total,s0[i].average);
            printf("----------------------------------------------------------------------------\n");
            printf("\n\n\n");
}
 

 

 

int main()                                                       //主函数
{
    int choose=0;
    num=0;                                                      //初始化学生个数为0
    welcome();
    meun();
    scanf("%d",&choose);
    printf("\n");
    while(choose>0&&choose<9)
    {
        switch(choose)
        {
        case 1:Add();system("pause");break;
        case 2:Delete();system("pause");break;
        case 3:modify() ;system("pause");break;
        case 4:search();system("pause");break;
        case 5:{
            int choose1;
            meun1();
            scanf("%d",&choose1);
            printf("\n");
            while(choose1>0&&choose1<4)
            {
                switch(choose1)
                {
                case 1:chinese ();system("pause");break;
                case 2:math ();system("pause");break;
                case 3:english ();system("pause");break;
                }
                printf("\n");
                meun1();
                scanf("%d",&choose1);
                printf("\n");
               }
               }
            ;system("pause");break;
        case 6: {
            int choose2=0;meun2();
            scanf("%d",&choose2);
            printf("\n");
            while(choose2>0&&choose2<4)
            {                 
                switch(choose2)
                {
                case 1:chinese_Sort();system("pause");break;
                case 2:math_Sort();system("pause");break;
                case 3:english_Sort();system("pause");break;
                }
                printf("\n");
                meun2();
                scanf("%d",&choose2);
                printf("\n");
            }
            }
            ;system("pause");break;
        case 7:total_Sort();system("pause");break;
        case 8:no_Sort();system("pause");break;
        }
        printf("\n");
        meun();
        scanf("%d",&choose);
        printf("\n");
    }
  printf("\n\n\t\t\t谢谢使用学生成绩管理系统,再见!\n\n\n\n");
  printf("\t\t\t\t版权所有,翻版必究\n\n\n\n");
  getchar();
}

2012-05-22 11:41
user_qiangzi
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:137
专家分:194
注 册:2011-8-29
收藏
得分:0 
代码真长。。。。。。。
2012-05-22 12:35
快速回复:求指导,求帮助!!!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.028131 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved