| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 986 人关注过本帖
标题:我是C语言新手,刚学不久,可以帮帮我看看这程序吗?
取消只看楼主 加入收藏
yintaiyuan
Rank: 1
等 级:新手上路
帖 子:21
专家分:1
注 册:2009-11-2
结帖率:77.78%
收藏
已结贴  问题点数:20 回复次数:4 
我是C语言新手,刚学不久,可以帮帮我看看这程序吗?
学生成绩管理系统: 对学生的成绩信息进行管理,学生信息包括:学号、姓名、学期、每门课程的成绩、平均成绩、名次。实现:学生信息的录入;修改;删除和查询,按学期、学号、成绩不及格等查询。

我自己编这个编个一个下午了,我辛勤的汗水啊!!!最后才发现一大堆错误,就是不会改,哪位好心人能帮帮我?居然连结构体声明那里也说我错了?

#include <stdio.h>
#include <string.h>

void menu(void)
{
 printf("1. information input\n");
 printf("2. information revise\n");
 printf("3. information delete\n");
 printf("4. information search\n");
 printf("Please enter your choice:");
}
main()
{
 int a, i, j;
 char c;
 struct STUDENT
 {
  int num;
  char name[10];
  int term;
  int scoreMath;
  int scoreEnglish;
  int scoreChinese;
  float average;
  int sum;
 };
 printf("please enter student number:");
 scanf("%d",&a);
 struct STUDENT stu[a];
4: menu();
 c=getchar();
 switch(c)
 {
  case '1':
           struct STUDENT abc;
           printf("please enter student num:");
           for(i=0;i<a;i++)
           {
            scanf("%d", &stu[i].num);
           }
           printf("please enter student name:");
           for(i=0;i<a;i++)
           {
            scanf("%s", stu[i].name);
           }
           printf("please enter term:");
           for(i=0;i<a;i++)
           {
            scanf("%d", &stu[i].term);
           }
           printf("please enter student scoreMath:");
           for(i=0;i<a;i++)
           {
            scanf("%d", &stu[i].scoreMath);
           }
           printf("please enter student scoreEnglish:");
           for(i=0;i<a;i++)
           {
            scanf("%d", &stu[i].scoreEnglish);
           }
           printf("please enter student scoreChinese:");
           for(i=0;i<a;i++)
           {
            scanf("%d", &stu[i].scoreChinese);
           }
           for(i=0;i<a;i++)
           {
            stu[i].sum=stu[i].scoreMath+stu[i].scoreEnglish+stu[i].scoreChinese;
            stu[i].average=stu[i].sum/4;
           }
           for(i=0;i<a-1;i++)
           {
            for(j=i+1;j<a;j++)
            {
             if(stu[j].sum > stu[i].sum)
             {
              abc=stu[i];
              stu[i]=stu[j];
              stu[j]=abc;
             }
            }
           }              
           for(i=0;i<a;i++)
           {
            printf("NO. : %d  Name : %s  Term : %d  ScoreMath : %d  ScoreEnglish : %d  ScoreChinese : %d  Sum : %d  Average : %f  Place: %d ", stu[i].num, stu[i].name, stu[i].term, stu[i].scoreMath, stu[i].scoreEnglish, stu[i].scoreChinese, stu[i].sum,  stu[i].average, i+1 );
           }
           goto 4;
           break;
  case '2':
           int c;
           char p;
           printf("please enter student num:");
           scanf("%d", &c);
           printf("please choice the error:");
           printf("1. num\n");
           printf("2. name\n");
           printf("3. term\n");
           printf("4. scoreMath\n");
           printf("5. scoreEnglish:");
           printf("6. scoreChinese:");
           printf("Please enter your choice:");
           p=getchar();
           switch(p)
           {
            case '1':
                     printf("please enter the new one:")
                     scanf("%d", &stu[c].num);
                     break;
            case '2':
                     printf("please enter the new one:")
                     scanf("%d", stu[c].name);
                     break;
            case '3':
                     printf("please enter the new one:")
                     scanf("%d", &stu[c].term);
                     break;
            case '4':
                     printf("please enter the new one:")
                     scanf("%d", &stu[c].scoreMath);
                     break;
            case '5':
                     printf("please enter the new one:")
                     scanf("%d", &stu[c].scoreEnglish);
                     break;

            case '6':
                     printf("please enter the new one:")
                     scanf("%d", &stu[c].scoreChinese);
                     break;
            default:
                    printf("Input error!");
           }
           for(i=0;i<a;i++)
           {
            stu[i].sum=stu[i].scoreMath+stu[i].scoreEnglish+stu[i].scoreChinese;
            stu[i].average=stu[i].sum/4;
           }
           for(i=0;i<a-1;i++)
           {
            for(j=i+1;j<a;j++)
            {
             if(stu[j].sum > stu[i].sum)
             {
              abc=stu[i];
              stu[i]=stu[j];
              stu[j]=abc;
             }
            }
           }              
           for(i=0;i<a;i++)
           {
            printf("NO. : %d  Name : %s  Term : %d  ScoreMath : %d  ScoreEnglish : %d  ScoreChinese : %d  Sum : %d  Average : %f  Place: %d ", stu[i].num, stu[i].name, stu[i].term, stu[i].scoreMath, stu[i].scoreEnglish, stu[i].scoreChinese, stu[i].sum,  stu[i].average, i+1 );
           }
           goto 4;
           break;
  case '3':
           int d;
           printf("Please enter the delete number:");
           scanf("%d", &d);
           for(i=0;i<a;i++)
           {
            if(d==stu[i].num)
            {
             for(i=0;i<a-1;i++)
             {
              stu[i]=stu[i+1];
             }
            goto 1;
            }      
           }
        1: for(i=0;i<a-1;i++)
           {
            printf("NO. : %d  Name : %s  Term : %d  ScoreMath : %d  ScoreEnglish : %d  ScoreChinese : %d  Sum : %d  Average : %f  Place: %d ", stu[i].num, stu[i].name, stu[i].term, stu[i].scoreMath, stu[i].scoreEnglish, stu[i].scoreChinese, stu[i].sum,  stu[i].average, i+1 );
           }
           goto 4;
           break;
  case '4':
           char u;
           printf("please choice the information your want to search:");
           printf("1. num\n");
           printf("2. name\n");
           printf("Please enter your choice:");
           u=getchar();
           switch(u)
           {
            case '1':
                     int e;
                     printf("Please enter the number:");
                     scanf("%d", &e);
                     for(i=0;i<a;i++)
                     {
                      if(e==stu[i].num)
                      {
            printf("NO. : %d  Name : %s  Term : %d  ScoreMath : %d  ScoreEnglish : %d  ScoreChinese : %d  Sum : %d  Average : %f  Place: %d ", stu[i].num, stu[i].name, stu[i].term, stu[i].scoreMath, stu[i].scoreEnglish, stu[i].scoreChinese, stu[i].sum,  stu[i].average, i+1 );
                      goto 2;                     
                      }
                     }
                    2: break;
            case '2':
                     char mm[10]:
                     printf("Please enter the name:");
                     scanf("%s", mm);
                     for(i=0;i<a;i++)
                     {
                      if(strcmp(mm, stu[i].name) == 0 )
                      {
            printf("NO. : %d  Name : %s  Term : %d  ScoreMath : %d  ScoreEnglish : %d  ScoreChinese : %d  Sum : %d  Average : %f  Place: %d ", stu[i].num, stu[i].name, stu[i].term, stu[i].scoreMath, stu[i].scoreEnglish, stu[i].scoreChinese, stu[i].sum,  stu[i].average, i+1 );
                      goto 3;                     
                      }
                     }
                    3: break;
            default:
                    printf("Input error!");
           }
           goto 4;
           break;
  default:
          printf("Input error!");
          goto 4;
 }
}
                                 

                     
搜索更多相关主题的帖子: C语言 
2010-03-03 20:28
yintaiyuan
Rank: 1
等 级:新手上路
帖 子:21
专家分:1
注 册:2009-11-2
收藏
得分:0 
图片附件: 游客没有浏览图片的权限,请 登录注册
错误截图,其他截不了。谢谢!
2010-03-03 20:45
yintaiyuan
Rank: 1
等 级:新手上路
帖 子:21
专家分:1
注 册:2009-11-2
收藏
得分:0 
回复 4楼 浅墨
29:struct STUDENT stu[a];  数组声明或定义时不能用变量作为下标 应改为常量 或者宏

但是我把a改成10,也显示同样的错误啊。
2010-03-03 21:08
yintaiyuan
Rank: 1
等 级:新手上路
帖 子:21
专家分:1
注 册:2009-11-2
收藏
得分:0 
谁可以帮我改改啊~
2010-03-04 12:39
yintaiyuan
Rank: 1
等 级:新手上路
帖 子:21
专家分:1
注 册:2009-11-2
收藏
得分:0 
回复 8楼 陈大师
谢谢你啊,在VC下编译是可以通过的,但是在TC2.0上编译很多错误,有办法可以在TC2.0上通过吗?谢谢!
2010-03-04 23:14
快速回复:我是C语言新手,刚学不久,可以帮帮我看看这程序吗?
数据加载中...
 
   



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

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