| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1539 人关注过本帖
标题:求修改 学生成绩管理系统
只看楼主 加入收藏
lx398134
Rank: 1
等 级:新手上路
帖 子:3
专家分:8
注 册:2015-11-24
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:2 
求修改 学生成绩管理系统
vc6.0可以运行,但好多错误。。。
哪位大神帮忙修改一下
我已经改的自己都不认识自己了
#include <stdio.h>
#define M 50
struct student
{
long num;  
char name[10];  
int chinese,english,math,sum,average;      
};  
void new_student(struct student students[]);  
void search_student(struct student students[],int num);
void row_student(struct student students[]);  
void delete_student(struct student students[],int num);
void modify_student(struct student students[],int num);
int count=0;   
main()  
{
    int choice,num;  
    struct student students[M];
    printf("╔══════学生成绩管理系统══════╗\n");   
    printf("║                                        ║\n");
    printf("║                                        ║\n");
    printf("║      1.录入             2.查找         ║\n");
    printf("║                                        ║\n");
    printf("║      3.排名             4.删除         ║\n");
    printf("║                                        ║\n");
    printf("║      5.修改             0.退出         ║\n");
    printf("║                                        ║\n");
    printf("╚════════════════════╝\n");
    printf("\n");
do
{  
    printf("  *   1:输入   2:查询  3:排序   4:删除    0:退出     *\n");
    scanf("%d",&choice);
    switch(choice)
{
    case 1:
        new_student(students);
        break;         
    case 2:
        printf("请输入查询学生的学号:");
        scanf("%d",&num);
        search_student(students,num);
        break;  
    case 3:
        row_student(students);
        break;         
    case 4:
        printf("请输入要删除学生的学号:");
        scanf("%d",&num);
        delete_student(students,num);
        break;
    case 5:
        printf("请输入要修改的学生学号:");
        scanf("%d",&num);
        modify_student(students,num);
    case 0:
        break;
    default :
    printf("输入有误,请重新选择\n");
    break;
    }
}
while(choice!=0);   
printf("结束\n");
return 0;
}
/*插入*/
void new_student(struct student students[])
{  
    struct student s;
    if(count==M){
    printf("已满\n");
    return;
    }
    printf("请输入第%d个学生学号,姓名,语文,英语,数学成绩:\n",count+1);
    scanf("%d%s%d%d%d",s.num,&s.name,&s.chinese,&s.english,&s.math);
    s.sum=s.chinese+s.english+s.math;
    s.average=s.sum/3.0;
    students[count]=s;
    count++;
}
/*查询*/
void search_student(struct student students[],int num)
{
    int i;
    for(i=0;i<count;i++)
    {  
        if(students[i].num==num)      
        {
            printf("学生信息如下:\n");
            printf ("学号   姓名   语文   英语    数学    总分    平均分\n");   
            printf("%-8d%-8s%-8d%-8d%-8d%-8d%-8f\n",students[i].num,students[i].name, students[i].chinese,students[i].english,students[i].math,students[i].sum,students[i].average);
            break;
        }        
        else
            printf("无此学生信息\n");
    }
}
/*排序*/
void row_student(struct student students[])
{
    int i,j,index;  
    struct student temp;
    for(i=0;i<count-1;i++)   
    {
        index=i;  
        for(j=i+1;j<count;j++)     
        {  
            if(students[j].sum>students[index].sum)   
            {
                index=j;  
                temp=students[index];  
                students[index]=students[i];
                students[i]=temp;
            }
        }
    }
    printf("成绩排序如下:\n");  
    printf ("学号   姓名   语文   英语    数学    总分    平均分\n");
    for(i=0;i<count;i++)      
        printf("%-8d%-8s%-8d%-8d%-8d%-8d%-8f\n",students[i].num,students[i].name, students[i].chinese,students[i].english,students[i].math,students[i].sum,students[i].average);
}
/*删除*/
void delete_student(struct student students[],int num)
{
    int i;  
    for(i=0;i<count;i++)     
    {
        if(students[i].num==num)
            printf("删除成功\n");
        do        
        {
            students[i]=students[i+1];
            i++;
        }
        while(i<count-1);
    }
}
/*修改*/
void modify_student(struct student students[],int num)
{
    int i;  
    for(i=0;i<count;i++)  
    {  
        if(students[i].num==num)      
        {
            printf("你要修改的学生信息为:\n");
            printf ("学号   姓名   语文   英语    数学    总分    平均分\n");
            printf("%-8d%-8s%-8d%-8d%-8d%-8d%-8f\n",students[i].num,students[i].name, students[i].chinese,students[i].english,students[i].math,students[i].sum,students[i].average);
            printf("-- 请输入新值--\n");
            printf("请输入学号:");
            scanf("%s",&students[i].num);
            getchar();
            printf("请输入姓名:");
            scanf("%s",&students[i].name);
            getchar();
            printf("请输入语文成绩:");
            scanf("%f",&students[i].chinese);
            getchar();
            printf("请输入数学成绩:");
            scanf("%f",&students[i].math);
            getchar();
            printf("请输入英语成绩:");
            scanf("%f",&students[i].english);
            getchar();
            students[i].sum=students[i].chinese+students[i].math+students[i].english;
            students[i].average=students[i].sum/3.0;
        }
        else
        {
            printf("学生不存在!\n");
        }
        printf("是否继续?(y/n)");
        if (getchar()=='n')
        {
            break;
        }
    }
}

搜索更多相关主题的帖子: 管理系统 english average include 认识自己 
2016-06-29 18:29
grmmylbs
Rank: 14Rank: 14Rank: 14Rank: 14
等 级:贵宾
威 望:54
帖 子:1409
专家分:5845
注 册:2016-2-14
收藏
得分:20 
程序代码:
#include <stdio.h> 
#define M 50 
struct student
{
    long num;
    char name[10];
    int chinese, english, math, sum ;
    float average;
};
void new_student(struct student students[]);
void search_student(struct student students[], int num);
void row_student(struct student students[]);
void delete_student(struct student students[], int num);
void modify_student(struct student students[], int num);
int count = 0;
main()
{
    int choice, num;
    struct student students[M];
    printf("╔══════学生成绩管理系统══════╗\n");
    printf("║                                        ║\n");
    printf("║                                        ║\n");
    printf("║      1.录入             2.查找         ║\n");
    printf("║                                        ║\n");
    printf("║      3.排名             4.删除         ║\n");
    printf("║                                        ║\n");
    printf("║      5.修改             0.退出         ║\n");
    printf("║                                        ║\n");
    printf("╚════════════════════╝\n");
    printf("\n");
    do
    {
        printf("  *   1:输入   2:查询  3:排序   4:删除    0:退出     *\n");
        scanf("%d", &choice);
        switch (choice)
        {
        case 1:
            new_student(students);
            break;
        case 2:
            printf("请输入查询学生的学号:");
            scanf("%d", &num);
            search_student(students, num);
            break;
        case 3:
            row_student(students);
            break;
        case 4:
            printf("请输入要删除学生的学号:");
            scanf("%d", &num);
            delete_student(students, num);
            break;
        case 5:
            printf("请输入要修改的学生学号:");
            scanf("%d", &num);
            modify_student(students, num);
        case 0:
            break;
        default:
            printf("输入有误,请重新选择\n");
            break;
        }
    } while (choice != 0);
    printf("结束\n");
    return 0;
}
/*插入*/
void new_student(struct student students[])
{
    struct student s;
    if (count == M) {
        printf("已满\n");
        return;
    }
    printf("请输入第%d个学生学号,姓名,语文,英语,数学成绩:\n", count + 1);
    scanf("%d%s%d%d%d", &s.num, s.name, &s.chinese, &s.english, &s.math);
    s.sum = s.chinese + s.english + s.math;
    s.average = s.sum / 3.0;
    students[count] = s;
    count++;
}
/*查询*/
void search_student(struct student students[], int num)
{
    int i;
    for (i = 0; i<count; i++)
    {
        if (students[i].num == num)
        {
            printf("学生信息如下:\n");
            printf("学号   姓名   语文   英语    数学    总分    平均分\n");
            printf("%-8d%-8s%-8d%-8d%-8d%-8d%-8f\n", students[i].num, students[i].name, students[i].chinese, students[i].english, students[i].math, students[i].sum, students[i].average);
            break;
        }
        else
            printf("无此学生信息\n");
    }
}
/*排序*/
void row_student(struct student students[])
{
    int i, j, index;
    struct student temp;
    for (i = 0; i<count - 1; i++)
    {
        index = i;
        for (j = i + 1; j<count; j++)
        {
            if (students[j].sum>students[index].sum)
            {
                index = j;
                temp = students[index];
                students[index] = students[i];
                students[i] = temp;
            }
        }
    }
    printf("成绩排序如下:\n");
    printf("学号   姓名   语文   英语    数学    总分    平均分\n");
    for (i = 0; i<count; i++)
        printf("%-8d%-8s%-8d%-8d%-8d%-8d%-8f\n", students[i].num, students[i].name, students[i].chinese, students[i].english, students[i].math, students[i].sum, students[i].average);
}
/*删除*/
void delete_student(struct student students[], int num)
{
    int i;
    for (i = 0; i<count; i++)
    {
        if (students[i].num == num)
            printf("删除成功\n");
        do
        {
            students[i] = students[i + 1];
            i++;
        } while (i<count - 1);
    }
}
/*修改*/
void modify_student(struct student students[], int num)
{
    int i;
    for (i = 0; i<count; i++)
    {
        if (students[i].num == num)
        {
            printf("你要修改的学生信息为:\n");
            printf("学号   姓名   语文   英语    数学    总分    平均分\n");
            printf("%-8d%-8s%-8d%-8d%-8d%-8d%-8f\n", students[i].num, students[i].name, students[i].chinese, students[i].english, students[i].math, students[i].sum, students[i].average);
            printf("-- 请输入新值--\n");
            printf("请输入学号:");
            scanf("%d", &students[i].num);
            getchar();
            printf("请输入姓名:");
            scanf("%s", &students[i].name);
            getchar();
            printf("请输入语文成绩:");
            scanf("%d", &students[i].chinese);
            getchar();
            printf("请输入数学成绩:");
            scanf("%d", &students[i].math);
            getchar();
            printf("请输入英语成绩:");
            scanf("%d", &students[i].english);
            getchar();
            students[i].sum = students[i].chinese + students[i].math + students[i].english;
            students[i].average = students[i].sum / 3.0;
        }
        else
        {
            printf("学生不存在!\n");
        }
        printf("是否继续?(y/n)");
        if (getchar() == 'n')
        {
            break;
        }
    }
}
2016-06-29 18:47
lx398134
Rank: 1
等 级:新手上路
帖 子:3
专家分:8
注 册:2015-11-24
收藏
得分:0 
回复 2楼 grmmylbs
非常非常感谢,不过还有些小bug,比如说多条记录删除一条,会重复显示上一条,我自己再调一调试试
2016-06-30 11:01
快速回复:求修改 学生成绩管理系统
数据加载中...
 
   



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

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