| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 4452 人关注过本帖
标题:c语言学生成绩统计
只看楼主 加入收藏
lbqiang
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2014-12-2
收藏
 问题点数:0 回复次数:2 
c语言学生成绩统计
学期考试结束,统计某班每个人的平均成绩,每门课的平均成绩,并按个人平均成绩从高到低的顺序输出成绩,输出不及格人名单。输入、输出格式自定。
考试课程有:高等数学、物理、外语、C语言4门课程。要求:
录入所有同学的成绩,对数据进行处理,输出所要求的内容,程序的功能主要包括以下几个方面:输入成绩、修改记录、删除记录、输出成绩并按平均成绩排序、并标记平均分不及格的学生、界面提供上述功能选择、学生人数由软件根据输入的成绩记录数自动控制、提供输出成绩到文件以及从文件读取成绩功能。

   不是计算机学院的学生写这种代码表示很杯具
搜索更多相关主题的帖子: 计算机学院 高等数学 c语言 C语言 统计 
2014-12-02 15:56
冷曦。
Rank: 2
来 自:苏州
等 级:论坛游民
帖 子:20
专家分:22
注 册:2015-7-27
收藏
得分:0 
是也很悲剧好嘛、、、
这种程序都老长老长的!

毋伤他人、尽尔所欲~
2015-08-01 21:39
冷曦。
Rank: 2
来 自:苏州
等 级:论坛游民
帖 子:20
专家分:22
注 册:2015-7-27
收藏
得分:0 
程序代码:
#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>
#include<string.h>
 struct sc
{
    int chinese;
    int maths;
    int english;
};

typedef struct node
{
    int num;
    char name[20];
    struct sc score;
    struct node *next;
}st;

int menu()//菜单
{
    int choice;
    do{ 
        system("cls");
        printf("\t1.input the messega about a student\n");
        
        printf("\t2.insect a messega of a new student\n");
        
        printf("\t3.look for the messega\n");
        
        printf("\t4.dellect the messega\n");
        
        printf("\t5.arranging base on the number of learning\n");
        
        printf("\t6.output all the messega\n");
        
        printf("\t7.arranging base on all scores\n");

        printf("\t8.exit the system\n");
        
        printf("\tplease input your choice:");
        
        scanf("%d",&choice);
    }while(choice>7&&choice<1);
    return choice;
}

st *create()//创建链表
{
    st *head,*p,*tail;
    char c;
    head=tail=NULL;
    while(c!='n'&&c!='N')
    {
       
        p=(st *)malloc(sizeof(st));
    p->next=NULL;
    printf("\t\tplease input the number of learning:");
    scanf("%d",&p->num);
    
    printf("\t\tplease input the name:");
    scanf("%s",p->name);
    
    printf("\t\tplease input the score of chinese:");
    scanf("%d",&p->score.chinese);
    
    printf("\t\tplease input the score of maths:");
    scanf("%d",&p->score.maths);
    
    printf("\t\tplease input the score of english:");
    scanf("%d",&p->score.english);
    if(head==NULL)
    
        head=tail=p;
    else
    {
        tail->next=p;
        tail=p;
    }
    
    printf("\t\tcontinue or stop(Y/N):");
    scanf("%s",&c);
    }
    return head;
}

st *arrange(st *head)// 以学号排名
{
    st *p,*q;
    int t,i=1,j,chinese,maths,english;
    char name[20];
    p=head;
    if(head==NULL)
        printf("\t\tNoting to arrange\n");
    else
    {
    do
    {
        j=1;
        while(p->next!=NULL)
        { 
            q=p->next;
            if(p->num>=q->num)
            {
                t=p->num;
                p->num=q->num;
                q->num=t;
                
                strcpy(name,p->name);
                   strcpy(p->name,q->name);
                strcpy(q->name,name);  

                chinese=p->score.chinese;
                p->score.chinese=q->score.chinese;
                q->score.chinese=chinese;

                maths=p->score.maths;
                p->score.maths=q->score.maths;
                q->score.maths=maths;

                english=p->score.english;
                p->score.english=q->score.english;
                q->score.english=english;

}
            p=q;
            j++;
        }
        p=head;
        i++;
    }while(i!=j);
    }
    return head;
}

st *arrangeall(st *head)//以总分排名
{
    st *p,*q;
    int t,i=1,j,chinese,maths,english;
    char name[20];
    p=head;
    if(head==NULL)
        printf("\t\tNoting to arrange\n");
    else
    {
    do
    {
        j=1;
        while(p->next!=NULL)
        { 
            q=p->next;
            if(p->score.chinese+p->score.maths+p->score.english<q->score.chinese+q->score.maths+q->score.english)
            {
                t=p->num;
                p->num=q->num;
                q->num=t;
                
                strcpy(name,p->name);
                   strcpy(p->name,q->name);
                strcpy(q->name,name);  

                chinese=p->score.chinese;
                p->score.chinese=q->score.chinese;
                q->score.chinese=chinese;

                maths=p->score.maths;
                p->score.maths=q->score.maths;
                q->score.maths=maths;

                english=p->score.english;
                p->score.english=q->score.english;
                q->score.english=english;

}
            p=q;
            j++;
        }
        p=head;
        i++;
    }while(i!=j);
    }
    return head;
}

st *insect(st *head,st *t)//插入学生的信息
{
    st *p,*q;
    p=head;
    if(head==NULL)
        printf("\tThe list is empty\n");
    else
    {

    if(t->num==p->num)
    {
        head=t;
        t->next=p;
    }
    else
    {
        while(p->next!=NULL)
        {
            q=p->next;
            if(p->num<=t->num&&q->num>=t->num)
            {
                t->next=q;
                p->next=t;
            }
            p=q;
        }
        p->next=t;
    }
    }
    return head;
}

void output(st *head)//输出所以学生的信息
{
    st *p;
    int i=0;
    float sum1=0,sum2=0,sum3=0;
    p=head;
    if(head==NULL)
    {
        printf("\tThere is nothing \n");
        return;
    }
    else
    {
        printf("\tnumber    name    chinese     maths    english       allscores\n");
        while(p)
        {
            printf("\t %d ",p->num);
            printf("   %s  ",p->name);
            printf("        %d ",p->score.chinese);
            printf("        %d ",p->score.maths);
            printf("        %d ",p->score.english);
            printf("%6d",p->score.chinese+p->score.maths+p->score.english);
            printf("\n");
            p=p->next;
        }
        
         p=head;
         while(p)// avrege scores
         {
            sum1+= p->score.chinese;
            sum2+=p->score.maths;
            sum3+=p->score.english;
            p=p->next;
            i++;
         }
         printf("\tarvege            %.2f        %.2f     %.2f          %.2f \n",sum1/i,sum2/i,sum3/i,(sum1+sum2+sum3)/i);

}
system("pause");
}

st *dellect(st *head,st *d)//删除学生的信息
{
    st *p,*q;
    char c;
    p=head;
    if(!(strcmp(p->name,d->name)))
    {
        head=p->next;
        free(p);
    }
    else 
    {
        while((strcmp(p->name,d->name))&&p->next!=NULL)
        {   
            q=p;
            p=q->next;
        }
        if(!(strcmp(p->name,d->name)))
        {
            printf("do you want to delete %S ?(Y/N):",p->name);
            scanf("%s",&c);
            
            if(c=='y'||c=='Y')
            {
        q->next=p->next;
        free(p);
            }
        }
        else
            printf("\tThere isn't this name\n");
    }
    
    return head;
}

void find(st *head,st *s)//查找学生的信息
{
    st *p,*q;
    p=head;
    if(head==NULL)
        printf("\tThe list is empty\n");
    else
    {

    while((strcmp(p->name,s->name))!=0&&p->next!=NULL)
    {
    
            q=p;
          p=q->next;
    }
    
           if((strcmp(p->name,s->name))==0) 
           
           {
               printf("\t %d ",p->num);
            printf(" %s ",p->name);
            printf(" chinese=%d ",p->score.chinese);
            printf(" maths=%d ",p->score.maths);
            printf(" english=%d ",p->score.english);
            printf("all=%d",p->score.chinese+p->score.maths+p->score.english);
            printf("\n");
           }    
           else
           printf("\tThe name is missing\n");
    }
           system("pause");
}

void main()//主函数
{
    st *head,*t,*s,*d;
    int choice;

    for(;;)
    {
        choice=menu();
        switch(choice)
        {
        
        case 1: 
            head=create();
            break;
        
        case 2:
            t=(st *)malloc(sizeof(st));
            t->next=NULL;
            printf("\t\tplease input the number of learning:");
    scanf("%d",&t->num);
    
    printf("\t\tplease input the name:");
    scanf("%s",t->name);
    
    printf("\t\tplease input the score of chinese:");
    scanf("%d",&t->score.chinese);
    
    printf("\t\tplease input the score of maths:");
    scanf("%d",&t->score.maths);
    
    printf("\t\tplease input the score of english:");
    scanf("%d",&t->score.english);

    head=insect(head,t);
    break;
        
        case 4:
            
            d=(st *)malloc(sizeof(st));
            d->next=NULL;
            printf("\twhice student do you want to dellect?please input the name:");
            scanf("%s",d->name);
            head=dellect(head,d);
            break;
        
        case 3:
            
            s=(st *)malloc(sizeof(st));
            s->next=NULL;
            printf("\twhice student do you want to look for?please input the name:");
            scanf("%s",s->name);
            find(head,s);
            break;
        
        case 5:
            head=arrange(head);//number
            break;
        
        case 6:
            output(head);
            break;
        case 7:
            head=arrangeall(head);//score
            break;
        
        case 8:
            printf("\t\tThank you,goodbye\n");
    exit(0);
        }
    }

}
类似于这个?

毋伤他人、尽尔所欲~
2015-08-01 21:43
快速回复:c语言学生成绩统计
数据加载中...
 
   



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

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