鱼C论坛

 找回密码
 立即注册
查看: 3119|回复: 7

请高手看看我这个程序哪错了?

[复制链接]
发表于 2012-8-26 22:40:31 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
  1. #include<iostream.h>
  2. #include<string>
  3. using namespace std;
  4. int main()
  5. {
  6.         //定义部分
  7.         int G,C,X;//G:年纪个数  C:班级个数  X:自定义班级人数
  8.         int a,b,c;//用于循环时的年级、班级和座号
  9.         register int o,p,q;
  10.         register int h;//判断是否
  11.         register int e,f,g;// 寄存器变量。查找、删除、更改时年级、班级和座号
  12.         const int I=100;//一个班级最多容纳100人
  13.         
  14.         //界面输出
  15.         cout<<"**********************************"<<endl;
  16.         cout<<"*        学生成绩管理系统        *"<<endl;
  17.         cout<<"*--------------------------------*"<<endl;
  18.         cout<<"*注意 :                         *"<<endl;
  19.         cout<<"*  该软件各班级仅记录100个学生! *"<<endl;
  20.         cout<<"*  并且要求各年段班级数一致 !   *"<<endl;
  21.         cout<<"**********************************"<<endl;
  22.         cout<<endl;
  23.         
  24.         cout<<"请输入年级数 :";
  25.         cin>>G;
  26.         cout<<"请输入各年级的班级数 :";
  27.         cin>>C;
  28.         string Na[G][C][I];//名字数组
  29.         float Ch[G][C][I];//语文成绩
  30.         float En[G][C][I];//英语成绩
  31.         float Ma[G][C][I];//数学成绩
  32.         double Total_C[G][C];//各班总成绩
  33.         double Total_G[G];//各年段总成绩
  34.         //主界面
  35.         ZJM://转向语句语句标号在此!!!
  36.         cout<<"1、录入学生成绩"<<endl;
  37.         cout<<"2、更改学生成绩"<<endl;
  38.         cout<<"3、删除学生成绩"<<endl;
  39.         cout<<"4、查看学生成绩"<<endl;
  40.         cout<<"5、添加学生成绩"<<endl;
  41.         cout<<"请输入 : ";
  42.         int j;
  43.         cin>>j;
  44.         if(j==1)
  45.                 goto RR;
  46.         else if(j==2)
  47.                 goto GG;
  48.         else if(j==3)
  49.                 goto SC;
  50.         else if(j==4)
  51.                 goto CK;
  52.         else if(j==5)
  53.                 goto TJ;
  54.         else
  55.                 {
  56.                         cout<<"输入错误!"<<endl;
  57.                         goto ZJM;
  58.                 }
  59.         //1、录入学生成绩
  60.         //goto语句标号于此,以条件语句和转向语句循环年级、班级
  61.         cout<<"请输入"<<a+1<<"年"<<b+1<<"班成绩"<<endl;
  62.         cout<<"请输入该班级人数 : ";
  63.         cin>>X;
  64.         a=0;
  65.         b=0;
  66.         
  67.         RR:
  68.         for(c=0;c<X;c++)
  69.         {
  70.                 cout<<"学生姓名 : ";
  71.                 cin>>Na[a][b][c];
  72.                 cout<<"请输入语文成绩 : ";
  73.                 cin>>o;
  74.                 Ch[a][b][c]=o;
  75.                 cout<<'\n'<<"请输入数学成绩 : ";
  76.                 cin>>p;
  77.                 Ma[a][b][c]=p;
  78.                 cout<<'\n'<<"请输入英语成绩 : ";
  79.                 cin>>q;
  80.                 En[a][b][c]=q;
  81.                 cout<<endl;
  82.                 for(int d=0;d<c;d++)
  83.                 {
  84.                         Total_C[a][b]+=(Ch[a][b][d]+Ma[a][b][d]+En[a][b][d]);
  85.                         //计算班级总分
  86.                 }
  87.         }
  88.         PD:
  89.         cout<<"返回主界面或继续输入下一个班级成绩?"<<endl;;
  90.         cout<<"1 :返回主界面  0 :继续下一个班级成绩"<<endl;
  91.         cout<<"请选择 : ";
  92.         cin>>h;
  93.         if (h==1)
  94.         {
  95.                 _sleep(1000);
  96.                 goto ZJM;//返回主界面
  97.         }
  98.         else if (h==0)
  99.         {
  100.                 if(a<G+1&&b<C+1)//班级数加1,录入下一个班级成绩
  101.                 {
  102.                         b++;
  103.                         goto RR;
  104.                 }
  105.                 if(a<G+1&&b==C+1)//该年级录入完成,录入下一个年级
  106.                 {
  107.                         a++;
  108.                         b=0;
  109.                         goto RR;
  110.                 }
  111.                 else//全部录入完成
  112.                 {
  113.                         cout<<"成绩录入完成,返回主界面"<<endl;
  114.                         _sleep(1000);
  115.                         goto ZJM;
  116.                 }
  117.         }
  118.         else
  119.         {
  120.                 cout<<"错误!"<<endl;
  121.                 _sleep(1000);
  122.                 goto PD;
  123.         }
  124.         
  125.         
  126.         //2、更改学生成绩
  127.         //goto语句标号于此,以条件语句和转向语句循环年级、班级
  128.         GG:
  129.         cout<<"请输入年级 : ";
  130.         cin>>e;
  131.         cout<<'\n'<<"请输入班级 : ";
  132.         cin>>f;
  133.         cout<<'\n'<<"请输入座号 : ";
  134.         cin>>g;
  135.         cout<<"原来成绩为 : "<<endl;
  136.         cout<<Na[e][f][g]<<" : ";
  137.         cout<<"语文 "<<Ch[e][f][g]<<" , 数学"<<Ma[e][f][g]<<" , 英语"<<En[e][f][g];
  138.         cout<<"请输入新成绩 :"<<endl;
  139.         cout<<"请输入语文成绩 : ";
  140.         cin>>Ch[e][f][g];
  141.         cout<<'\n'<<"请输入数学成绩 : ";
  142.         cin>>Ma[e][f][g];
  143.         cout<<'\n'<<"请输入英语成绩 : ";
  144.         cin>>En[e][f][g];
  145.         GGFJ:
  146.         cout<<"是否继续更改其他学生的成绩?"<<endl;
  147.         cout<<"1:是  0:否,返回主界面"<<endl;
  148.         cout<<"请输入 : ";
  149.         cin>>h;
  150.         if (h==1)
  151.         {
  152.                 _sleep(1000);
  153.                 goto GG;
  154.         }
  155.         else if(h==0)
  156.         {
  157.                 _sleep(1000);
  158.                 goto ZJM;
  159.         }
  160.         else
  161.         {
  162.                 cout<<"错误!"<<endl;
  163.                 goto GGFJ;
  164.         }
  165.         
  166.         //3、删除学生成绩
  167.         //goto语句标号于此,以条件语句和转向语句循环年级、班级
  168.         SC:
  169.         cout<<"请输入年级 : ";
  170.         cin>>e;
  171.         cout<<'\n'<<"请输入班级 : ";
  172.         cin>>f;
  173.         cout<<'\n'<<"请输入座号 : ";
  174.         cin>>g;
  175.         cout<<endl;
  176.         cout<<Na[e][f][g]<<" : ";
  177.         cout<<"语文 "<<Ch[e][f][g]<<" , 数学"<<Ma[e][f][g]<<" , 英语"<<En[e][f][g];
  178.         SCFJ:
  179.         cout<<"确定删除?"<<endl;
  180.         cout<<"1:是  0:否"<<endl;
  181.         cout<<"请输入 : ";
  182.         cin>>h;
  183.         if (h==1)
  184.         {
  185.                 Ch[e][f][g]=0;
  186.                 Ma[e][f][g]=0;
  187.                 En[e][f][g]=0;
  188.                 cout<<"操作成功!"<<endl;
  189.                 SCFJJ:
  190.                 cout<<"是否返回主界面?"<<endl;
  191.                 cout<<"1:是  0:否"<<endl;
  192.                 cout<<"请输入 : ";
  193.                 cin>>h;
  194.                 if(h==1)
  195.                 {
  196.                         _sleep(1000);
  197.                         goto ZJM;
  198.                 }
  199.                 else if(h==0)
  200.                 {
  201.                         _sleep(1000);
  202.                         goto SC;
  203.                 }
  204.                 else
  205.                 {
  206.                         cout<<"错误!"<<endl;
  207.                         goto SCFJJ;
  208.                 }
  209.         }
  210.         else if (h==0)
  211.         {
  212.                 _sleep(1000);
  213.                 goto SC;
  214.         }
  215.         else
  216.         {
  217.                 cout<<"错误!"<<endl;
  218.                 goto SCFJ;
  219.         }
  220.         
  221.         //4、查看学生成绩
  222.         //goto语句标号于此,以条件语句和转向语句循环年级、班级
  223.         CK:
  224.         cout<<"请注意只能查看一个班级全部学生的成绩!"<<endl;
  225.         cout<<"请输入年级 :";
  226.         cin>>e;
  227.         cout<<'\n'<<"请输入班级 :";
  228.         cin>>f;
  229.         for(int x=0;x<=X;x++)
  230.         {
  231.                 cout<<Na[e][f][x]<<" : ";
  232.                 cout<<"语文 "<<Ch[e][f][x]<<" , 数学"<<Ma[e][f][x]<<" , 英语"<<En[e][f][x];
  233.         }
  234.         CKFJ:
  235.         cout<<"是否继续查看其他班级?"<<endl;
  236.         cout<<"1:是 0:否,返回主界面"<<endl;
  237.         cout<<"请输入 : ";
  238.         cin>>h;
  239.         if(h==1)
  240.         {
  241.                 _sleep(1000);
  242.                 goto CK;
  243.         }
  244.         else if(h==0)
  245.         {
  246.                 _sleep(1000);
  247.                 goto ZJM;
  248.         }
  249.         else
  250.         {
  251.                 cout<<"错误!"<<endl;
  252.                 goto CKFJ;
  253.         }
  254.         //5、添加学生成绩
  255.         //goto语句标号于此,以条件语句和转向语句循环年级、班级
  256.         TJ:
  257.         cout<<"请输入年级 : "<<endl;
  258.         cin>>e;
  259.         cout<<"请输入班级 : "<<endl;
  260.         cin>>f;
  261.         cout<<"请输入座号 : "<<endl;
  262.         cin>>g;
  263.         if (Na[e][f][g]!="\0")
  264.         {
  265.                 cout<<"该数组已经有数据了!"<<endl;
  266.                 goto TJ;
  267.         }
  268.         cout<<"请输入语文成绩 : ";
  269.         cin>>Ch[e][f][g];
  270.         cout<<'\n'<<"请输入数学成绩 : ";
  271.         cin>>Ma[e][f][g];
  272.         cout<<'\n'<<"请输入英语成绩 : ";
  273.         cin>>En[e][f][g];
  274.         cout<<"是否继续添加学生成绩?"<<endl;
  275.         cout<<"1:是  0:否,返回主界面"<<endl;
  276.         cout<<"请输入 : ";
  277.         cin>>h;
  278.         if(h==1)
  279.         {
  280.                 _sleep(1000);
  281.                 goto TJ;
  282.         }
  283.         else if(h==0)
  284.         {
  285.                 _sleep(1000);
  286.                 goto ZJM;
  287.         }
  288.         else
  289.         {
  290.                 cout<<"错误!"<<endl;
  291.                 goto TJ;
  292.         }
  293.         return 0;
  294. }
复制代码
我这个程序运行不能正确运行,请高手请教,我这个程序都有哪些错误
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2012-8-26 22:51:46 | 显示全部楼层
加头文件#include<stdio.h>
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2012-8-27 00:03:16 | 显示全部楼层
三藏取经,多多指教
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2012-8-27 11:38:15 | 显示全部楼层
好长啊....过两年再看...
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2012-8-27 11:48:17 | 显示全部楼层
  1. //#include<iostream.h>
  2. #include<iostream>
  3. #include<string>
  4. using namespace std;
  5. int main()
  6. {
  7.         //定义部分
  8.         const int G=2,C=1,X=1;//G:年纪个数  C:班级个数  X:自定义班级人数
  9.         int a,b,c;//用于循环时的年级、班级和座号
  10.         register int o,p,q;
  11.         register int h;//判断是否
  12.         register int e,f,g;// 寄存器变量。查找、删除、更改时年级、班级和座号
  13.         const int I=100;//一个班级最多容纳100人
  14.         
  15.         //界面输出
  16.         cout<<"**********************************"<<endl;
  17.         cout<<"*        学生成绩管理系统        *"<<endl;
  18.         cout<<"*--------------------------------*"<<endl;
  19.         cout<<"*注意 :                         *"<<endl;
  20.         cout<<"*  该软件各班级仅记录100个学生! *"<<endl;
  21.         cout<<"*  并且要求各年段班级数一致 !   *"<<endl;
  22.         cout<<"**********************************"<<endl;
  23.         cout<<endl;
  24.         
  25.         //cout<<"请输入年级数 :";
  26.        // cin>>G;
  27.         //cout<<"请输入各年级的班级数 :";
  28.        // cin>>C;
  29.         string Na[G][C][I];//名字数组
  30.         float Ch[G][C][I];//语文成绩
  31.         float En[G][C][I];//英语成绩
  32.         float Ma[G][C][I];//数学成绩
  33.         double Total_C[G][C];//各班总成绩
  34.         double Total_G[G];//各年段总成绩
  35.         //主界面
  36.         ZJM://转向语句语句标号在此!!!
  37.         cout<<"1、录入学生成绩"<<endl;
  38.         cout<<"2、更改学生成绩"<<endl;
  39.         cout<<"3、删除学生成绩"<<endl;
  40.         cout<<"4、查看学生成绩"<<endl;
  41.         cout<<"5、添加学生成绩"<<endl;
  42.         cout<<"请输入 : ";
  43.         int j;
  44.         cin>>j;
  45.         if(j==1)
  46.                 goto RR;
  47.         else if(j==2)
  48.                 goto GG;
  49.         else if(j==3)
  50.                 goto SC;
  51.         else if(j==4)
  52.                 goto CK;
  53.         else if(j==5)
  54.                 goto TJ;
  55.         else
  56.                 {
  57.                         cout<<"输入错误!"<<endl;
  58.                         goto ZJM;
  59.                 }
  60.         //1、录入学生成绩
  61.         //goto语句标号于此,以条件语句和转向语句循环年级、班级
  62.         cout<<"请输入"<<a+1<<"年"<<b+1<<"班成绩"<<endl;
  63.         //cout<<"请输入该班级人数 : ";
  64.         //cin>>X;
  65.         a=0;
  66.         b=0;
  67.         
  68.         RR:
  69.         for(c=0;c<X;c++)
  70.         {
  71.                 cout<<"学生姓名 : ";
  72.                 cin>>Na[a][b][c];
  73.                 cout<<"请输入语文成绩 : ";
  74.                 cin>>o;
  75.                 Ch[a][b][c]=o;
  76.                 cout<<'\n'<<"请输入数学成绩 : ";
  77.                 cin>>p;
  78.                 Ma[a][b][c]=p;
  79.                 cout<<'\n'<<"请输入英语成绩 : ";
  80.                 cin>>q;
  81.                 En[a][b][c]=q;
  82.                 cout<<endl;
  83.                 for(int d=0;d<c;d++)
  84.                 {
  85.                         Total_C[a][b]+=(Ch[a][b][d]+Ma[a][b][d]+En[a][b][d]);
  86.                         //计算班级总分
  87.                 }
  88.         }
  89.         PD:
  90.         cout<<"返回主界面或继续输入下一个班级成绩?"<<endl;;
  91.         cout<<"1 :返回主界面  0 :继续下一个班级成绩"<<endl;
  92.         cout<<"请选择 : ";
  93.         cin>>h;
  94.         if (h==1)
  95.         {
  96.                 _sleep(1000);
  97.                 goto ZJM;//返回主界面
  98.         }
  99.         else if (h==0)
  100.         {
  101.                 if(a<G+1&&b<C+1)//班级数加1,录入下一个班级成绩
  102.                 {
  103.                         b++;
  104.                         goto RR;
  105.                 }
  106.                 if(a<G+1&&b==C+1)//该年级录入完成,录入下一个年级
  107.                 {
  108.                         a++;
  109.                         b=0;
  110.                         goto RR;
  111.                 }
  112.                 else//全部录入完成
  113.                 {
  114.                         cout<<"成绩录入完成,返回主界面"<<endl;
  115.                         _sleep(1000);
  116.                         goto ZJM;
  117.                 }
  118.         }
  119.         else
  120.         {
  121.                 cout<<"错误!"<<endl;
  122.                 _sleep(1000);
  123.                 goto PD;
  124.         }
  125.         
  126.         
  127.         //2、更改学生成绩
  128.         //goto语句标号于此,以条件语句和转向语句循环年级、班级
  129.         GG:
  130.         cout<<"请输入年级 : ";
  131.         cin>>e;
  132.         cout<<'\n'<<"请输入班级 : ";
  133.         cin>>f;
  134.         cout<<'\n'<<"请输入座号 : ";
  135.         cin>>g;
  136.         cout<<"原来成绩为 : "<<endl;
  137.         cout<<Na[e][f][g]<<" : ";
  138.         cout<<"语文 "<<Ch[e][f][g]<<" , 数学"<<Ma[e][f][g]<<" , 英语"<<En[e][f][g];
  139.         cout<<"请输入新成绩 :"<<endl;
  140.         cout<<"请输入语文成绩 : ";
  141.         cin>>Ch[e][f][g];
  142.         cout<<'\n'<<"请输入数学成绩 : ";
  143.         cin>>Ma[e][f][g];
  144.         cout<<'\n'<<"请输入英语成绩 : ";
  145.         cin>>En[e][f][g];
  146.         GGFJ:
  147.         cout<<"是否继续更改其他学生的成绩?"<<endl;
  148.         cout<<"1:是  0:否,返回主界面"<<endl;
  149.         cout<<"请输入 : ";
  150.         cin>>h;
  151.         if (h==1)
  152.         {
  153.                 _sleep(1000);
  154.                 goto GG;
  155.         }
  156.         else if(h==0)
  157.         {
  158.                 _sleep(1000);
  159.                 goto ZJM;
  160.         }
  161.         else
  162.         {
  163.                 cout<<"错误!"<<endl;
  164.                 goto GGFJ;
  165.         }
  166.         
  167.         //3、删除学生成绩
  168.         //goto语句标号于此,以条件语句和转向语句循环年级、班级
  169.         SC:
  170.         cout<<"请输入年级 : ";
  171.         cin>>e;
  172.         cout<<'\n'<<"请输入班级 : ";
  173.         cin>>f;
  174.         cout<<'\n'<<"请输入座号 : ";
  175.         cin>>g;
  176.         cout<<endl;
  177.         cout<<Na[e][f][g]<<" : ";
  178.         cout<<"语文 "<<Ch[e][f][g]<<" , 数学"<<Ma[e][f][g]<<" , 英语"<<En[e][f][g];
  179.         SCFJ:
  180.         cout<<"确定删除?"<<endl;
  181.         cout<<"1:是  0:否"<<endl;
  182.         cout<<"请输入 : ";
  183.         cin>>h;
  184.         if (h==1)
  185.         {
  186.                 Ch[e][f][g]=0;
  187.                 Ma[e][f][g]=0;
  188.                 En[e][f][g]=0;
  189.                 cout<<"操作成功!"<<endl;
  190.                 SCFJJ:
  191.                 cout<<"是否返回主界面?"<<endl;
  192.                 cout<<"1:是  0:否"<<endl;
  193.                 cout<<"请输入 : ";
  194.                 cin>>h;
  195.                 if(h==1)
  196.                 {
  197.                         _sleep(1000);
  198.                         goto ZJM;
  199.                 }
  200.                 else if(h==0)
  201.                 {
  202.                         _sleep(1000);
  203.                         goto SC;
  204.                 }
  205.                 else
  206.                 {
  207.                         cout<<"错误!"<<endl;
  208.                         goto SCFJJ;
  209.                 }
  210.         }
  211.         else if (h==0)
  212.         {
  213.                 _sleep(1000);
  214.                 goto SC;
  215.         }
  216.         else
  217.         {
  218.                 cout<<"错误!"<<endl;
  219.                 goto SCFJ;
  220.         }
  221.         
  222.         //4、查看学生成绩
  223.         //goto语句标号于此,以条件语句和转向语句循环年级、班级
  224.         CK:
  225.         cout<<"请注意只能查看一个班级全部学生的成绩!"<<endl;
  226.         cout<<"请输入年级 :";
  227.         cin>>e;
  228.         cout<<'\n'<<"请输入班级 :";
  229.         cin>>f;
  230.                 {//加这个是由于VC6的bug
  231.                         for(int x=0;x<=X;x++)
  232.                         {
  233.                 cout<<Na[e][f][x]<<" : ";
  234.                 cout<<"语文 "<<Ch[e][f][x]<<" , 数学"<<Ma[e][f][x]<<" , 英语"<<En[e][f][x];
  235.                         }
  236.                 }
  237.         CKFJ:
  238.         cout<<"是否继续查看其他班级?"<<endl;
  239.         cout<<"1:是 0:否,返回主界面"<<endl;
  240.         cout<<"请输入 : ";
  241.         cin>>h;
  242.         if(h==1)
  243.         {
  244.                 _sleep(1000);
  245.                 goto CK;
  246.         }
  247.         else if(h==0)
  248.         {
  249.                 _sleep(1000);
  250.                 goto ZJM;
  251.         }
  252.         else
  253.         {
  254.                 cout<<"错误!"<<endl;
  255.                 goto CKFJ;
  256.         }
  257.         //5、添加学生成绩
  258.         //goto语句标号于此,以条件语句和转向语句循环年级、班级
  259.         TJ:
  260.         cout<<"请输入年级 : "<<endl;
  261.         cin>>e;
  262.         cout<<"请输入班级 : "<<endl;
  263.         cin>>f;
  264.         cout<<"请输入座号 : "<<endl;
  265.         cin>>g;
  266.         if (Na[e][f][g]!="\0")
  267.         {
  268.                 cout<<"该数组已经有数据了!"<<endl;
  269.                 goto TJ;
  270.         }
  271.         cout<<"请输入语文成绩 : ";
  272.         cin>>Ch[e][f][g];
  273.         cout<<'\n'<<"请输入数学成绩 : ";
  274.         cin>>Ma[e][f][g];
  275.         cout<<'\n'<<"请输入英语成绩 : ";
  276.         cin>>En[e][f][g];
  277.         cout<<"是否继续添加学生成绩?"<<endl;
  278.         cout<<"1:是  0:否,返回主界面"<<endl;
  279.         cout<<"请输入 : ";
  280.         cin>>h;
  281.         if(h==1)
  282.         {
  283.                 _sleep(1000);
  284.                 goto TJ;
  285.         }
  286.         else if(h==0)
  287.         {
  288.                 _sleep(1000);
  289.                 goto ZJM;
  290.         }
  291.         else
  292.         {
  293.                 cout<<"错误!"<<endl;
  294.                 goto TJ;
  295.         }
  296.         return 0;
  297. }
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2012-8-27 11:48:19 | 显示全部楼层
  1. //#include<iostream.h>
  2. #include<iostream>
  3. #include<string>
  4. using namespace std;
  5. int main()
  6. {
  7.         //定义部分
  8.         const int G=2,C=1,X=1;//G:年纪个数  C:班级个数  X:自定义班级人数
  9.         int a,b,c;//用于循环时的年级、班级和座号
  10.         register int o,p,q;
  11.         register int h;//判断是否
  12.         register int e,f,g;// 寄存器变量。查找、删除、更改时年级、班级和座号
  13.         const int I=100;//一个班级最多容纳100人
  14.         
  15.         //界面输出
  16.         cout<<"**********************************"<<endl;
  17.         cout<<"*        学生成绩管理系统        *"<<endl;
  18.         cout<<"*--------------------------------*"<<endl;
  19.         cout<<"*注意 :                         *"<<endl;
  20.         cout<<"*  该软件各班级仅记录100个学生! *"<<endl;
  21.         cout<<"*  并且要求各年段班级数一致 !   *"<<endl;
  22.         cout<<"**********************************"<<endl;
  23.         cout<<endl;
  24.         
  25.         //cout<<"请输入年级数 :";
  26.        // cin>>G;
  27.         //cout<<"请输入各年级的班级数 :";
  28.        // cin>>C;
  29.         string Na[G][C][I];//名字数组
  30.         float Ch[G][C][I];//语文成绩
  31.         float En[G][C][I];//英语成绩
  32.         float Ma[G][C][I];//数学成绩
  33.         double Total_C[G][C];//各班总成绩
  34.         double Total_G[G];//各年段总成绩
  35.         //主界面
  36.         ZJM://转向语句语句标号在此!!!
  37.         cout<<"1、录入学生成绩"<<endl;
  38.         cout<<"2、更改学生成绩"<<endl;
  39.         cout<<"3、删除学生成绩"<<endl;
  40.         cout<<"4、查看学生成绩"<<endl;
  41.         cout<<"5、添加学生成绩"<<endl;
  42.         cout<<"请输入 : ";
  43.         int j;
  44.         cin>>j;
  45.         if(j==1)
  46.                 goto RR;
  47.         else if(j==2)
  48.                 goto GG;
  49.         else if(j==3)
  50.                 goto SC;
  51.         else if(j==4)
  52.                 goto CK;
  53.         else if(j==5)
  54.                 goto TJ;
  55.         else
  56.                 {
  57.                         cout<<"输入错误!"<<endl;
  58.                         goto ZJM;
  59.                 }
  60.         //1、录入学生成绩
  61.         //goto语句标号于此,以条件语句和转向语句循环年级、班级
  62.         cout<<"请输入"<<a+1<<"年"<<b+1<<"班成绩"<<endl;
  63.         //cout<<"请输入该班级人数 : ";
  64.         //cin>>X;
  65.         a=0;
  66.         b=0;
  67.         
  68.         RR:
  69.         for(c=0;c<X;c++)
  70.         {
  71.                 cout<<"学生姓名 : ";
  72.                 cin>>Na[a][b][c];
  73.                 cout<<"请输入语文成绩 : ";
  74.                 cin>>o;
  75.                 Ch[a][b][c]=o;
  76.                 cout<<'\n'<<"请输入数学成绩 : ";
  77.                 cin>>p;
  78.                 Ma[a][b][c]=p;
  79.                 cout<<'\n'<<"请输入英语成绩 : ";
  80.                 cin>>q;
  81.                 En[a][b][c]=q;
  82.                 cout<<endl;
  83.                 for(int d=0;d<c;d++)
  84.                 {
  85.                         Total_C[a][b]+=(Ch[a][b][d]+Ma[a][b][d]+En[a][b][d]);
  86.                         //计算班级总分
  87.                 }
  88.         }
  89.         PD:
  90.         cout<<"返回主界面或继续输入下一个班级成绩?"<<endl;;
  91.         cout<<"1 :返回主界面  0 :继续下一个班级成绩"<<endl;
  92.         cout<<"请选择 : ";
  93.         cin>>h;
  94.         if (h==1)
  95.         {
  96.                 _sleep(1000);
  97.                 goto ZJM;//返回主界面
  98.         }
  99.         else if (h==0)
  100.         {
  101.                 if(a<G+1&&b<C+1)//班级数加1,录入下一个班级成绩
  102.                 {
  103.                         b++;
  104.                         goto RR;
  105.                 }
  106.                 if(a<G+1&&b==C+1)//该年级录入完成,录入下一个年级
  107.                 {
  108.                         a++;
  109.                         b=0;
  110.                         goto RR;
  111.                 }
  112.                 else//全部录入完成
  113.                 {
  114.                         cout<<"成绩录入完成,返回主界面"<<endl;
  115.                         _sleep(1000);
  116.                         goto ZJM;
  117.                 }
  118.         }
  119.         else
  120.         {
  121.                 cout<<"错误!"<<endl;
  122.                 _sleep(1000);
  123.                 goto PD;
  124.         }
  125.         
  126.         
  127.         //2、更改学生成绩
  128.         //goto语句标号于此,以条件语句和转向语句循环年级、班级
  129.         GG:
  130.         cout<<"请输入年级 : ";
  131.         cin>>e;
  132.         cout<<'\n'<<"请输入班级 : ";
  133.         cin>>f;
  134.         cout<<'\n'<<"请输入座号 : ";
  135.         cin>>g;
  136.         cout<<"原来成绩为 : "<<endl;
  137.         cout<<Na[e][f][g]<<" : ";
  138.         cout<<"语文 "<<Ch[e][f][g]<<" , 数学"<<Ma[e][f][g]<<" , 英语"<<En[e][f][g];
  139.         cout<<"请输入新成绩 :"<<endl;
  140.         cout<<"请输入语文成绩 : ";
  141.         cin>>Ch[e][f][g];
  142.         cout<<'\n'<<"请输入数学成绩 : ";
  143.         cin>>Ma[e][f][g];
  144.         cout<<'\n'<<"请输入英语成绩 : ";
  145.         cin>>En[e][f][g];
  146.         GGFJ:
  147.         cout<<"是否继续更改其他学生的成绩?"<<endl;
  148.         cout<<"1:是  0:否,返回主界面"<<endl;
  149.         cout<<"请输入 : ";
  150.         cin>>h;
  151.         if (h==1)
  152.         {
  153.                 _sleep(1000);
  154.                 goto GG;
  155.         }
  156.         else if(h==0)
  157.         {
  158.                 _sleep(1000);
  159.                 goto ZJM;
  160.         }
  161.         else
  162.         {
  163.                 cout<<"错误!"<<endl;
  164.                 goto GGFJ;
  165.         }
  166.         
  167.         //3、删除学生成绩
  168.         //goto语句标号于此,以条件语句和转向语句循环年级、班级
  169.         SC:
  170.         cout<<"请输入年级 : ";
  171.         cin>>e;
  172.         cout<<'\n'<<"请输入班级 : ";
  173.         cin>>f;
  174.         cout<<'\n'<<"请输入座号 : ";
  175.         cin>>g;
  176.         cout<<endl;
  177.         cout<<Na[e][f][g]<<" : ";
  178.         cout<<"语文 "<<Ch[e][f][g]<<" , 数学"<<Ma[e][f][g]<<" , 英语"<<En[e][f][g];
  179.         SCFJ:
  180.         cout<<"确定删除?"<<endl;
  181.         cout<<"1:是  0:否"<<endl;
  182.         cout<<"请输入 : ";
  183.         cin>>h;
  184.         if (h==1)
  185.         {
  186.                 Ch[e][f][g]=0;
  187.                 Ma[e][f][g]=0;
  188.                 En[e][f][g]=0;
  189.                 cout<<"操作成功!"<<endl;
  190.                 SCFJJ:
  191.                 cout<<"是否返回主界面?"<<endl;
  192.                 cout<<"1:是  0:否"<<endl;
  193.                 cout<<"请输入 : ";
  194.                 cin>>h;
  195.                 if(h==1)
  196.                 {
  197.                         _sleep(1000);
  198.                         goto ZJM;
  199.                 }
  200.                 else if(h==0)
  201.                 {
  202.                         _sleep(1000);
  203.                         goto SC;
  204.                 }
  205.                 else
  206.                 {
  207.                         cout<<"错误!"<<endl;
  208.                         goto SCFJJ;
  209.                 }
  210.         }
  211.         else if (h==0)
  212.         {
  213.                 _sleep(1000);
  214.                 goto SC;
  215.         }
  216.         else
  217.         {
  218.                 cout<<"错误!"<<endl;
  219.                 goto SCFJ;
  220.         }
  221.         
  222.         //4、查看学生成绩
  223.         //goto语句标号于此,以条件语句和转向语句循环年级、班级
  224.         CK:
  225.         cout<<"请注意只能查看一个班级全部学生的成绩!"<<endl;
  226.         cout<<"请输入年级 :";
  227.         cin>>e;
  228.         cout<<'\n'<<"请输入班级 :";
  229.         cin>>f;
  230.                 {//加这个是由于VC6的bug
  231.                         for(int x=0;x<=X;x++)
  232.                         {
  233.                 cout<<Na[e][f][x]<<" : ";
  234.                 cout<<"语文 "<<Ch[e][f][x]<<" , 数学"<<Ma[e][f][x]<<" , 英语"<<En[e][f][x];
  235.                         }
  236.                 }
  237.         CKFJ:
  238.         cout<<"是否继续查看其他班级?"<<endl;
  239.         cout<<"1:是 0:否,返回主界面"<<endl;
  240.         cout<<"请输入 : ";
  241.         cin>>h;
  242.         if(h==1)
  243.         {
  244.                 _sleep(1000);
  245.                 goto CK;
  246.         }
  247.         else if(h==0)
  248.         {
  249.                 _sleep(1000);
  250.                 goto ZJM;
  251.         }
  252.         else
  253.         {
  254.                 cout<<"错误!"<<endl;
  255.                 goto CKFJ;
  256.         }
  257.         //5、添加学生成绩
  258.         //goto语句标号于此,以条件语句和转向语句循环年级、班级
  259.         TJ:
  260.         cout<<"请输入年级 : "<<endl;
  261.         cin>>e;
  262.         cout<<"请输入班级 : "<<endl;
  263.         cin>>f;
  264.         cout<<"请输入座号 : "<<endl;
  265.         cin>>g;
  266.         if (Na[e][f][g]!="\0")
  267.         {
  268.                 cout<<"该数组已经有数据了!"<<endl;
  269.                 goto TJ;
  270.         }
  271.         cout<<"请输入语文成绩 : ";
  272.         cin>>Ch[e][f][g];
  273.         cout<<'\n'<<"请输入数学成绩 : ";
  274.         cin>>Ma[e][f][g];
  275.         cout<<'\n'<<"请输入英语成绩 : ";
  276.         cin>>En[e][f][g];
  277.         cout<<"是否继续添加学生成绩?"<<endl;
  278.         cout<<"1:是  0:否,返回主界面"<<endl;
  279.         cout<<"请输入 : ";
  280.         cin>>h;
  281.         if(h==1)
  282.         {
  283.                 _sleep(1000);
  284.                 goto TJ;
  285.         }
  286.         else if(h==0)
  287.         {
  288.                 _sleep(1000);
  289.                 goto ZJM;
  290.         }
  291.         else
  292.         {
  293.                 cout<<"错误!"<<endl;
  294.                 goto TJ;
  295.         }
  296.         return 0;
  297. }
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
 楼主| 发表于 2012-8-27 21:38:29 | 显示全部楼层
大家运行一下会发现。在输入姓名后就卡死了,然后就得退出,这是怎么回事呢?
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2012-8-27 22:25:29 | 显示全部楼层
看完楼主的帖子,我在想还要不要学C语言了、、、
小甲鱼最新课程 -> https://ilovefishc.com
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-11-14 20:38

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表