| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 506 人关注过本帖
标题:为什么没错误不能运行啊
只看楼主 加入收藏
张倚川
Rank: 1
等 级:新手上路
帖 子:40
专家分:0
注 册:2011-6-11
结帖率:54.55%
收藏
已结贴  问题点数:20 回复次数:2 
为什么没错误不能运行啊
/****头文件*****/
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
/**************变量的定义**************/
int b,c,i,j,k,m,n,t,w,z,stu,a[100][10];
long num;
int *p;
char ch,filename[10];
FILE *fp,*fp1;
/******************函数的声明*******************/
main();             /*主函数*/
   System();        /*功能菜单*/
       Input();        /*函数的输入*/
          inputx();     /*成绩的输入*/
       Find();         /*成绩的查询*/
          find1();     /*按名次查询*/
          find2();     /*按学号查询*/
          find3(); /*选择查询科目*/
            find31(); /*按分数段查询*/
       Change();       /*添加、修改*/
          add();       /*成绩的添加*/
          del();       /*成绩的删除*/
          change();    /*成绩的修改*/
   Idea();             /*意见评述*/

/***************程序代码***************/

/******************输入学生成绩***************/
  inputx()
{    textbackground(5);
     textcolor(2);
      clrscr();
     gotoxy(25,9);
           printf("Please input the filename:");
           scanf("%s",filename);
     gotoxy(27,13);
           printf("请输入你们班学生人数:");
           scanf("%d",&stu);
     if((fp=fopen(filename,"w"))==NULL)
        {printf("Cannot open the file");
         exit(0);
         }
       clrscr();
     gotoxy(30,2);
           printf("请输入学生成绩");
           putchar('\n') ;
           printf("     学号    高数     外语    C言     组装   中医\n");
     for(i=0;i<=stu-1;i++)
        {for(j=0;j<=5;j++)
            {gotoxy(8*(j+1),i+4);
                  scanf("%6d",&a[i][j]);
             fputc(a[i][j],fp);
             }
             printf("\n");
         }
 }
/*******输出成绩表,并求总分,平均成绩*******/
 print1()
{     for(i=0;i<=stu-1;i++) /*求总分和平均分*/
         {   a[i][6]=0;
          for(j=1;j<=5;j++)
             a[i][6]+=a[i][j];
             a[i][7]=a[i][6]/5;
         }
      for(i=0;i<stu;i++)
         {   k=i;
             a[i][8]=i+1;
          for(j=i+i;j<=stu;j++)
             if(a[j][6]>a[k][6])
                  k=j;
               for(m=0;m<=7;m++)
                  {t=a[k][m];
                   a[k][m]=a[i][m];
                   a[i][m]=t;
                  }
         }
        for(i=0;i<=stu-1;i++)
         {for(j=0;j<=8;j++)
            
                  printf("%7d",a[i][j]);
            
          printf("\n");
         }
      fprintf(fp,"   学号  高数  外语  C言   组装  中医 总分  平均分 排名\n");
      for(i=0;i<=stu;i++)
         {for(j=0;j<=8;j++)
              fprintf(fp,"%4d",a[i][j]);
              fputc(a[i][j],fp);
              fprintf(fp,"\n");
         }
      fclose(fp);
}
/********************各科总分 及平均分**********************/
 Input()
{     inputx();
       clrscr();
      printf("                             输出学生成绩");
      gotoxy(3,2);
      for(i=1;i<=65;i++)
         printf("%");
         putchar('\n');
  printf("    学号   高数   外语    C言   组装    中医   总分 平均分  名次\n");
      print1();
      getch();
      clrscr();
      gotoxy(35,13);
            printf("谢谢使用此程序\n") ;
      getch();
}
/*************按名次查询*******************/
  find1()
{     printf("请输入名次\n");
      scanf("%d",&n);
      printf("   学号  高数  外语  C言   组装  中医  总分  平均分 排名\n");
      for(i=0;i<stu;i++)
         if(n==a[i][8])
            for(j=0;j<=8;j++)
                printf("%6d",a[i][j]);
      getch();
      Find();
}
/******************按学号查询**********************/
 find2()
{      printf("请输入所要查询学生的学号\n") ;
       scanf("%d",&n);
       printf("   学号  高数   外语  C言  组装  中医  总分 平均分  排名\n");
       for(i=0;i<stu;i++)
          if(n==a[i][0])
             for(j=0;j<=8;j++)
                 printf("%6d",a[i][j]);
       getch();
       Find();
}
/**********************按科目查询**************************/
 find31()
{       printf("请输入你要查询的成绩段\n");
        scanf("%d   %d",&m,&z);
        printf("   学号  高数  外语  C言   组装  中医 总分  平均分 排名\n");
        for(i=0;i<stu;i++)
           if(a[i][n]>=m && a[i][n]<=z)
               {for(j=0;j<=8;j++)
                    printf("%6d",a[i][j]);
                printf("\n");
               }
        getch();
        Find();
}
/**************查询的科目*****************/

 find3()
 {      printf("现有五种科目共查询:\n") ;
        printf("1 高数  2 外语  3 C言  4组装  5 中医\n") ;
        printf("请选择:");
        scanf("%d",&n);             /*选择科目*/
        switch(n)
              {case 1:  find31();
               case 2:  find31();
               case 3:  find31();
               case 4:  find31();
               case 5:  find31();
               default: clrscr();
                        gotoxy(35,8);
                        printf("Errors");
                        gotoxy(22,14);
                              printf("Please press any keyboard to back");
                        Find();
             }

        getch();
}
/*****************成绩的查询********************/
  Find()
{       textbackground(14);
        textcolor(13);
        clrscr();
        gotoxy(35,3);
               printf("查询菜单\n");
        gotoxy(25,7);
               printf("      1  按学生名次查询");
        gotoxy(25,9);
               printf("      2  按学生学号查询");
        gotoxy(25,11);
               printf("      3  查询单科成绩段");
        gotoxy(25,13);
               printf("      0  退回到功能菜单");
        for(t=1;t<=40;t++)
           {{gotoxy(20+t,5);
                    printf("\001");}
            {gotoxy(20+t,15);
                    printf("\001");}
           }
        putchar('\n');
        printf("Please input your choice:");
        scanf("%d",&m);
        if(m==1)
           find1();
        else if(m==2)
                find2();
             else if(m==3)
                     find3();
                  else if(m==0)
                        System();
                       else if(m!=1 && m!=2 && m!=3 && m!=0)
                               Find();

}
/****************成绩的添加*********************/
   add()         /*成绩的添加*/
{       fp=fopen(filename,"rb");     /*打开刚才输入的成绩*/
        printf("请输入你要添加的人数:");
        scanf("%d",&n);
        printf("请输入你要添加的成绩\n");
        printf("     学号    高数     外语    C言     组装   中医\n");
        for(i=stu;i<(stu+n);i++)
           {for(j=0;j<6;j++)
                {gotoxy(8*(j+1),i+8);
                 scanf("%4d",&a[i][j]);
                 }
            printf("\n");
           }
        clrscr();
        gotoxy(30,12);
        printf("请输入你们班学生人数:");
        scanf("%d",&stu);
        clrscr();
        printf("                      重新输出学生成绩\n");
  printf("   学号   高数    外语   C言    组装  中医   总分  平均分  排名\n");
        print1();
        getch();
        clrscr();
        Change();
}
/***************成绩的删除*******************/
 del()
{       clrscr();
        fp=fopen(filename,"rb");
        printf("请输入你要删除的学号\n");
        scanf("%d",&m);
        for(i=0;i<stu;i++)
            if(a[i][0]==m)
               for(j=0;j<=9;j++)
                   a[i][j]=0;
        printf("                      重新输出学生成绩\n");
   printf("   学号   高数    外语   C言    组装  中医   总分  平均分  排名\n");
        print1();
        getch();
        Change();
}
/*****************成绩的修改*********************/
   change1(n)
{       int p;
        fp=fopen(filename,"rb");
        printf("输入学号:");
        scanf("%d",&m);
        printf("请输入你改的成绩:");
        scanf("%d",&p);
        for(i=0;i<stu;i++)
            if(a[i][0]==m)
               a[i][n]=p;
        clrscr();
        printf("                      重新输出学生成绩\n");
    printf("   学号   高数    外语   C言    组装  中医   总分  平均分  排名\n");
        print1();
        getch();
        Change();
}
   change() /*选择修改方式*/
{       int n;
        clrscr();
        printf("你可以有以下修改方式 1 高数  2 外语 3 C言  4 组装 5 中医\n");
        printf("请选择修改方式:");
        scanf("%d",&n);
        change1(n);
}
/****************添加、修改菜单**********************/
  Change()
{       clrscr();
        printf("\n现在您将会遇到以下几种情况:\n");
        printf("1 添加; 2 删除; 3 修改; 0 返回;\n");
        printf("请您根据需要按键选择:");
        scanf("%d",&n);      /*选择菜单*/
        if(n==1)
           add();
        else if(n==2)
                del();
             else if(n==3)
                     change();
                  else if(n==0)
                          System();
}
/******************功能菜单*******************/
  System()
 {    B:
       {
        textbackground(10);
        textcolor(12);
         clrscr();
        gotoxy(25,3);
        for(i=1;i<=30;i++)
            printf("$");
        gotoxy(36,6);
               printf("功能菜单");
        gotoxy(32,9);
               printf("<1>:   成绩的输入");
        gotoxy(32,12);
               printf("<2>;   成绩的查询");
        gotoxy(32,15);
               printf("<3>;   添加、修改");
        gotoxy(32,18);
               printf("<0>;   退回主菜单");
        gotoxy(15,21);
        for(i=1;i<=53;i++)
            printf("$");
        gotoxy(25,23);
               printf("Please input your choice:");
        scanf("%d",&j);
       }
        switch(j)
              {case 1:   Input();    goto B;
               case 2:   Find();     goto B;
               case 3:   Change();   goto B;
               case 0:               break;
               default:  clrscr();
                         gotoxy(35,8);
                                printf("Errors");
                         gotoxy(22,14);
                                printf("Please press any keyboard to continue");
                         getch();
                         goto B;
              }

}
/*********************意见评述********************/
  Idea()
 {      textbackground(14);
        textcolor(10);
         clrscr();
        gotoxy(25,13);
              {printf("Please input your filename:");
               scanf("%s",filename);
              }
        if((fp1=fopen(filename,"w"))==NULL)
          {printf("Cannot open file\n");
           exit(0);
          }
         clrscr();
        gotoxy(36,3);
               printf("意见评述");
        putchar('\n');
        for(i=1;i<=80;i++)
            printf("^");
        gotoxy(40,5);
               printf("(请用English书写,以#号键结束)\n");
        getch();
     do
       {ch=getchar();
        if(ch=='#')
           continue;
        fputc(ch,fp1);
       }while(ch!='#');
        fclose(fp1);
         clrscr();
        gotoxy(20,13);
               printf("Please press any keyboard to back main menu ");
        getch();
      }
/****************主函数******************/
 main()
{     A:
       {
        textbackground(13);  /*背景颜色为黄色*/
        textcolor(15);      /*字符颜色为绿色*/
         clrscr();              /*清屏*/
        printf("\n                        ***欢迎使用学生成绩管理系统***\n");
        for(i=5;i<=72;i++)
           {gotoxy(i,4);
                   printf("*");
           }
        printf("\n");
        for(i=1;i<=60;i++)
           {gotoxy(8+i,6);
                   printf("#");
            gotoxy(8+i,21);
                   printf("#");
           }
        for(i=1;i<=16;i++)
           {gotoxy(9,5+i);
                   printf("#");
            gotoxy(68,5+i);
                   printf("#");
           }
        gotoxy(35,9);
               printf("主菜单");
        gotoxy(25,12);
               printf(" !<1>    功能菜单");
        gotoxy(25,15);
               printf(" !<2>    意见评述");
        gotoxy(25,18);
               printf(" !<0>    退出系统");
        gotoxy(5,23);
               printf("Please input your choice:");
        scanf("%d",&k);
}
        switch(k)
              {case 1:  clrscr();  System();    goto A;
               case 2:  clrscr();  Idea();      goto A;
               case 0:                          break;
               default: textbackground(6);
                        textcolor(2);
                         clrscr();
                        gotoxy(35,8);
                               printf("Errors");
                        gotoxy(20,15);
                               printf("Please press any keyboard to continue");

                        getch();
                        goto A;
              }
        printf("    Quit  ?\n");
        printf("    Press 1(Yes) or 2(No)  :");/* 数字1表示退出。
                                                  数字2表示不退出回到主菜单
                                                  其他数字表示错误回到主菜单。*/
        scanf("%d",&j);
        switch(j)
              {case 1:   clrscr();
                         gotoxy(30,8);
                                printf("Thank you to use\n");
                         gotoxy(22,15);
                                printf("Please press any keyboard to leave");
                         getch();
                         break;
               case 2:   goto A;
               default:  clrscr();
                         gotoxy(35,8);
                                printf("Errors");
                         gotoxy(20,15);
                         printf("Please press any keyboard to back main main");
                         getch(); goto A;
    }

}
搜索更多相关主题的帖子: 菜单 声明 include 
2011-12-16 14:01
embed_xuel
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:58
帖 子:3845
专家分:11385
注 册:2011-9-13
收藏
得分:10 
回复 楼主 张倚川
main函数怎么还在头文件里声明啊?

总有那身价贱的人给作业贴回复完整的代码
2011-12-16 14:10
lin471306489
Rank: 4
等 级:业余侠客
帖 子:136
专家分:247
注 册:2011-8-16
收藏
得分:10 
哥哥,你这程序回去好好改一改再拿出来大家看看
2011-12-16 15:13
快速回复:为什么没错误不能运行啊
数据加载中...
 
   



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

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