首页 > 用户发贴区 > 编程问题提问区 > 谁能帮我编写这个程序啊
2008
12-20

谁能帮我编写这个程序啊

建立一个学生信息资料管理系统。系统功能如下:
1、    记录10个以上学生的数据信息,包括学生的学号,姓名,性别,年龄,数学、物理、政治、英语和电子学等五门课程的成绩和平均成绩;(40分)
2、    系统中学生数据的排列顺序,初始时是按照输入顺序排列的;系统中数据顺序是可以变化的,根据使用者的选择,可以按照学号由低向高排序,也可以按照平均成绩由高向低排序;(40分)
3、    可以在系统中插入或删除一个学生的信息;(20分)
4、    编写的程序中,主函数是一个框架,主要是对库函数和自定义函数的调用。不允许将所有的语句全堆砌在一个主函数中,并建立较好的文档说明。


谁能帮我编写这个程序啊》有 2 条评论

  1. mcdz 说:

     #include”stdio.h”
    #include”string.h”
    #include”stdLib.h”
    void hyjm();
    void pass();
    void jm();
    void scan(struct stu st[],int n);
    void print(struct stu st[],int n);
    void ss(struct stu st[],int n);
    void zf(struct stu st[],int n);
    void dk(struct stu st[],int n);
    void xg(struct stu st[],int n);
    void sc(struct stu st[],int n);
    void bc(struct stu st[],int n);
    void dq(struct stu st[],int n);
    void tc();
    #define N 50

    static int stu=0;
    struct stu
    {
     char name[20];//名字
     char num[20];//学号
     char sex;//性别
     int age;//年龄
     float score[3];//成绩
     float sum;//总成绩
     float averge;//平均成绩
    }st[N];
    void main()
    {
     hyjm();
    }
    void hyjm()
    {
     char a;
     printf(“\n\n\n\n\n\n\n\n\t\t\t”);
     printf(“欢”);
     _sleep(200);
     printf(“迎”);
     _sleep(200);
     printf(“进”);
     _sleep(200);
     printf(“入”);
     _sleep(200);
     printf(“成”);
     _sleep(200);
     printf(“绩”);
     _sleep(200);
     printf(“管”);
     _sleep(200);
     printf(“理”);
     _sleep(200);
     printf(“系”);
     _sleep(200);
     printf(“统”);
     _sleep(400);
     printf(“\t\t   睿”);
     _sleep(200);
     printf(“水”);
     _sleep(200);
     printf(“汉”);
     _sleep(200);
     printf(“\n\n\n\t\t\tY是入     8是出\n\t\t\t”);
     scanf(“%c”,&a);
     if(a==’Y'||a==’y')
      pass();
     else if(a==’8′)
      exit(0);
    }
    void jm()
    {
     int v;
     char a=3,b=15;
     system(“cls”);
     while(1)
     {
      printf(“\n”);
      printf(“\t\t                  %c%c%c%c%c%c%c%c%c%c%c%c      \n”,b,b,b,b,b,b,b,b,b,b,b,b);
      printf(“\t\t                  学生管理系统                  \n”);
      printf(“\t\t|%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c|\n”,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a);
      printf(“\t\t|                                              |\n”);
      printf(“\t\t|                                              |\n”);
      printf(“\t\t|                                              |\n”);
      printf(“\t\t|%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c|\n”,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a);
      printf(“\t\t|                1. 增加记录                   |\n”);
      printf(“\t\t|                2. 显示记录                   |\n”);
      printf(“\t\t|                3. 搜索记录                   |\n”);
      printf(“\t\t|                4. 按总分排序显示记录         |\n”);
      printf(“\t\t|                5. 按单科排序显示记录         |\n”);
      printf(“\t\t|                6. 修改记录                   |\n”);
      printf(“\t\t|                7. 删除记录                   |\n”);
      printf(“\t\t|                8. 保存记录                   |\n”);
      printf(“\t\t|                9. 读取记录                   |\n”);
      printf(“\t\t|                0. 退出系统                   |\n”);
      printf(“\t\t|%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c|\n”,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a);
      printf(“\t\t %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c \n”,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a);
      printf(“选择(1-9):”);
      scanf(“%d”,&v);
      system(“cls”);
      switch(v)
      {
       case 1:scan(st,N);break;
       case 2:system(“cls”);print(st,N);system(“PAUSE”);system(“cls”);break;
       case 3:system(“cls”);ss(st,N);system(“PAUSE”);system(“cls”);break;
       case 4:system(“cls”);zf(st,N);print(st,N);system(“PAUSE”);system(“cls”);break;
       case 5:system(“cls”);dk(st,N);print(st,N);system(“PAUSE”);system(“cls”);break;
       case 6:system(“cls”);xg(st,N);system(“PAUSE”);system(“cls”);break;
       case 7:system(“cls”);sc(st,N);system(“PAUSE”);system(“cls”);break;
       case 8:system(“cls”);bc(st,N);system(“PAUSE”);system(“cls”);break;
       case 9:system(“cls”);dq(st,N);system(“PAUSE”);system(“cls”);break;
       case 0:tc();exit(0);break;
       default:printf(“你输入的不在范围之内,请重新输入!. \n”);break;
      }
     }
    }
    void pass()
    {
     int i,j=0;
     char pass[10]=”";
     char password[10]=”654321″;
     int z=0;
     int a=3;
     do
     {
      strcpy(pass,”");
     printf(“\n\t\t\t请输入密码:”);
     for(j=0;;)
      {
       pass[j]=getch();
       if(pass[j]==’\r’){pass[j]=’\0′;break;}
       else if(pass[j]==’\b’)
       {
        if(j==0);
        else
        {
         pass[j]=’\0′;
         pass[--j]=’\0′;
         printf(“\b \b”);
        }
       }
       else if(j>6)pass[j]=’\0′;
       else
       {
        printf(“*”);
        j++;
       }
      }
     if(strcmp(pass,password)==0)
          {
              printf(“\n\n\t\t\tloading”);
        for(i=0;i<6;i++)
        {
         printf(“.”);
         _sleep(200);
        }
              z=1;
              break;
          }
          else
          {
        printf(“\n\n\t\t\tloading”);
        for(i=0;i<6;i++)
        {
         printf(“.”);
         _sleep(500);
        }
        system(“cls”);
              printf(“\n\t\t\t密码错误  请重新输入!\n”);
              a–;
          }
     }while(a>0);
     if(z==0)
     {
      printf(“\t\t\t已经3次输入错误,请核对后再进入本系统.\n\n”);
      exit(0);
     }
     jm();
    }
    void scan(struct stu st[],int n)
    {
     
     int i,j,a,b;
     system(“cls”);
     for(i=stu;i<n;i++)
     {
      printf(“\n\n\t\t姓名:”);
      scanf(” %s”,st[i].name);
      printf(“\n\t\t学号:”);
      scanf(” %s”,st[i].num);
      for(b=0;b<stu;b++)
      {
       if(strcmp(st[i].num,st[b].num)==0)
       {
        printf(“\t你输入的学号已存在,请重新输入..\n”);
        do
        {
        printf(“\t\t学号:\n\t\t”);
        scanf(“%s”,st[i].num);
        }while(strcmp(st[i].num,st[b].num)==0);

       }
       else
        break;
      }
         printf(“\n\t\t性别(b/g):”);
      scanf(” %c”,&st[i].sex);
      if(st[i].sex!=’g’ && st[i].sex!=’b')
      {
       do
       {
       printf(“\n\t\t输入有误,输入的值为:(b) 或 (g)!!\n\n”);
       printf(“\t\t性别(b/g):”);
       scanf(” %c”,&st[i].sex);
       
       }while(st[i].sex!=’g’ && st[i].sex!=’b');
      }
      printf(“\n\t\t年龄:”);
      scanf(“%d”,&st[i].age);
      if(st[i].age>100)
      {
       do
       {
        printf(“\n\t\t输入有误,年龄范围再(0<age<100)\n\n”);
        printf(“\t\t年龄:”);
        scanf(” %d”,&st[i].age);

       }while(st[i].age>100);
      }
      printf(“\t\t      1. C语言       2. access       3. Dreamweaver\n”);
      st[i].sum=0;
      for(j=0;j<3;j++)
      {
       do
       {
        printf(“\n\t\t第%d的成绩:”,j+1);
        scanf(“%f”,&st[i].score[j]);
        if(st[i].score[j]>0&&st[i].score[j]<100)
        {
         st[i].sum=st[i].sum+st[i].score[j];
         break;
        }
        printf(“\n\t\t输入错误!分数的范围是(0<score<100)\n\n”);
       }while(1);
      }
      st[i].averge=st[i].sum/3;
      stu++;
      printf(“\t\t继续输入记录请按1.\t\t任意“数”返回上一层\n\t\t”);
      scanf(“%d”,&a);
      if(a==1)
       continue;
      else
       system(“cls”);   break;
     }
    }
    void print(struct stu st[],int n)
    {
     int i,j;
     printf(“姓名\t学号\t性别\t年龄\tC语言\taccess\tDreamweaver\t总分\t平均成绩\n”);
     for(i=0;i<stu;i++)
     {
      printf(“%s\t”,st[i].name);
      printf(“%s\t”,st[i].num);
      printf(“%c\t”,st[i].sex);
      printf(“%d\t”,st[i].age);
      for(j=0;j<3;j++)
      {
       printf(“%.2f\t”,st[i].score[j]);
      }
      printf(“\t%.2f\t%.2f”,st[i].sum,st[i].averge);
      printf(“\n”);
     }
    }
    void ss(struct stu st[],int n)
    {
     int i,j,q;
     char m[20];
     char z[20];
     int b;
     system(“cls”);
     printf(“选择搜索方式:\n”);
     do
     {
     printf(“1.按学号搜索\t2.按姓名搜索\n”);
     scanf(“%d”,&q);
     if(q!=1&&q!=2)
      printf(“你输入有误!重新输入!\n”);
     }while(q!=1&&q!=2);
     if(q==1)
     do
     {
     printf(“请输入搜索该学生的学号:”);
     scanf(“%s”,m);
     for(i=0;i<stu;i++)
     {
      if((strcmp(st[i].num,m))==0)
      {
       printf(“姓名\t学号\t性别\t年龄\tC语言\taccess\tDreamweaver\t总分\t平均成绩\n”);
       printf(“%s\t”,st[i].name);
       printf(“%s\t”,st[i].num);
       printf(“%c\t”,st[i].sex);
       printf(“%d\t”,st[i].age);
       for(j=0;j<3;j++)
       {
        printf(“%.2f\t”,st[i].score[j]);
       }
       printf(“\t%.2f\t%.2f”,st[i].sum,st[i].averge);
       printf(“\n”);
       break;
      }
     }
     if(i==stu)
     {
      printf(“\t\t你输入的学号不存在!\n重新输入请按1,任意数返回上一层:”);
      scanf(“%d”,&b); 
     }
     }while(b==1);
     if(q==2)
      do
      {
       printf(“请输入搜索该学生的姓名:”);
       scanf(“%s”,z);
       for(i=0;i<stu;i++)
       {
        if((strcmp(st[i].name,z))==0)
        {
         printf(“姓名\t学号\t性别\t年龄\tC语言\taccess\tDreamweaver\t总分\t平均成绩\n”);
         printf(“%s\t”,st[i].name);
         printf(“%s\t”,st[i].num);
         printf(“%c\t”,st[i].sex);
         printf(“%d\t”,st[i].age);
         for(j=0;j<3;j++)
         {
          printf(“%.2f\t”,st[i].score[j]);
         }
       printf(“\t%.2f\t%.2f”,st[i].sum,st[i].averge);
       printf(“\n”);
       break;
      }
     }
     if(i==stu)
     {
      printf(“\t\t你输入的学生姓名不存在!\n重新输入请按1,任意数返回上一层:”);
      scanf(“%d”,&b); 
     }
     }while(b==1);
    }
    void zf(struct stu st[],int n)
    {
     int i,j;
     struct stu temp;
     for(i=1;i<=n-1;i++)
     {
      for(j=0;j<=n-1-i;j++)
      {
       if(st[j].sum<st[j+1].sum)
       {
        temp=st[j];
        st[j]=st[j+1];
        st[j+1]=temp;
       }
      }
     }
     
    }
    void dk(struct stu st[],int n)
    {
     int i,j;
     int a;
     struct stu t;
     system(“cls”);
     do
     {
      printf(“\t请选择你想要排序的课程\t1  C语言\t2  access\t3  Dreamweaver:\n”);
      scanf(“%d”,&a);
      if(a!=1 && a!=2 && a!=3)
      {
       printf(“你输入的课程不存在,请重新输入\n”);
      }
     }while(a!=1 && a!=2 && a!=3);
     for(i=1;i<=n-1;i++)
     {
      for(j=0;j<=n-1-i;j++)
      {
       if(st[j].score[a-1]<st[j+1].score[a-1])
       {
        t=st[j];
        st[j]=st[j+1];
        st[j+1]=t;
       }
      }
     }
    }
    void xg(struct stu st[],int n)
    {
     int i,j,a,b,c;
     char h[20];
     float nscore[3],temp;
    ca: printf(“请输入修改的学号:”);
     scanf(“%s”,h);
     for(i=0;i<stu;i++)
     {
      if((strcmp(st[i].num,h))==0)
      {
       printf(“名字\t学号\t性别\t年龄\tC语言\taccess\tdreamweaver\t总分\t平均成绩\n”);
       printf(“%s\t”,st[i].name);
       printf(“%s\t”,st[i].num);
       printf(“%c\t”,st[i].sex);
       printf(“%d\t”,st[i].age);
       for(j=0;j<3;j++)
       {
        printf(“%.2f\t”,st[i].score[j]);
       }
       printf(“\t%.2f\t%.2f”,st[i].sum,st[i].averge);
    eeee:  printf(“\n请选择你要修改的课程序号..\n”);
       printf(“\t\t1.C语言\t\t2.access\t3.dreamweaver\n\t\t”);
       scanf(“%d”,&a);   
       switch(a)
       {
       case 1:case 2:case 3:
        printf(“请输入你要修改本科的成绩:”);
        scanf(“%f”,&nscore[a-1]);
        temp=st[i].score[a-1];
        st[i].score[a-1]=nscore[a-1];
        st[i].sum=st[i].sum-temp+st[i].score[a-1];
        st[i].averge=st[i].sum/3;
        system(“cls”);
        printf(“修改成功!\n”);
        printf(“按任意键返回主菜单..”);
        getch();
        jm();
        break;
       default:
        printf(“你输入的课程序号不存在..\n再次输入请按1,按其他数字键返回主菜单..”);
        scanf(“%d”,&c);
        if(c==1)
         goto eeee;
        else
        {
         system(“cls”);
         jm();
         break;
        }
          }   
      }
     }
     if(i==stu)
     {
      printf(“你输入的学号不存在!\n再次输入请按1,按其他数字键返回主菜单..”);
      scanf(“%d”,&b);
      if(b==1)
       goto ca;
      else
      {
       system(“cls”);
       jm();
      }
     }
    }
    void sc(struct stu st[],int n)
    {
     int i,j,a,b,q,w;
     char h[20];
     do
     {
      printf(“\t\t1.删除全部记录\t2.按学号删除\n\t\t”);
      scanf(“%d”,&b);
      if(b!=1&&b!=2)
       printf(“输入有误!请重新输入!\n\t\t”);
     }while(b!=1&&b!=2);
    /* if(b==1)
     {
      do
      {
       printf(“\t\t确认要删除全部记录?\t1.是  2.否\n\t\t”);
       scanf(“%d”,&w);
       if(w!=1&&w!=2)
        printf(“\t\t输入有误!请重新输入!\n\t\t”);
      }while(w!=1&&w!=2);
      if(w==1)
      {
       for(i=0;i<stu;i++)
       {
        stu[i]=0;///////////////////////////////////////////////////
       }
      }
      if(w==2)
       jm();
      }
     }*/
     if(b==2)
     do
     {
     printf(“请输入删除的学号:”);
     scanf(“%s”,h);
        for(i=0;i<n;i++)
        {
            if((strcmp(st[i].num,h))==0)
      {
       printf(“姓名\t学号\t性别\t年龄\tc语言\taccess\tdreamweaver\t总分\t平均成绩\n”);
       printf(“%s\t”,st[i].name);
       printf(“%s\t”,st[i].num);
       printf(“%c\t”,st[i].sex);
       printf(“%d\t”,st[i].age);
       for(j=0;j<3;j++)
       {
        printf(“%.1f\t”,st[i].score[j]);
       }
       printf(“%.2f\t%.2f”,st[i].sum,st[i].averge);
       printf(“\n”);
       printf(“你确定要删除此记录吗?确定请按1,取消请按0:”);
       scanf(“%d”,&a);
       if(a==1)
       {
        st[i]=st[i+1];
        stu–;
        printf(“删除成功!\n”);
        break;
       }
       else
        break;
      }
     }
     if(i==n)
     {
      printf(“输入的学号不存在!\n再次输入请按1,退出请按0:”);
      scanf(“%d”,&q);
     }
     }while(q==1);
     
    }
    void bc(struct stu st[],int n)
    {
     int i;
     FILE *fp;
     fp=fopen(“aa.txt”,”w+”);
     
     for(i=0;i<stu;i++)
     {
      
      fprintf(fp,”%s\t”,st[i].name);
      fprintf(fp,”%s\t”,st[i].num);  
      fprintf(fp,”%c\t”,st[i].sex);
      fprintf(fp,”%d\t”,st[i].age);
      fprintf(fp,”%.2f\t”,st[i].score[0]);
      fprintf(fp,”%.2f\t”,st[i].score[1]);
      fprintf(fp,”%.2f\t”,st[i].score[2]);
      fprintf(fp,”%.2f\t”,st[i].sum);
      fprintf(fp,”%.2f\t”,st[i].averge);  
      fprintf(fp,”\n”);
     }
     fclose(fp);
     printf(“\n保存完毕,按任意键返回主菜单…\n”);
     getch();
    }
    void dq(struct stu st[],int n)

     int i;
     FILE *fp;
     fp=fopen(“aa.txt”,”r”);
     if(fp==NULL)return;
     for(i=0;;i++)
     {
      fscanf(fp,” %s”,st[i].name);
      fscanf(fp,” %s”,st[i].num); 
      fscanf(fp,” %c”,&st[i].sex);
      fscanf(fp,”%d”,&st[i].age);
      fscanf(fp,”%f”,&st[i].score[0]);
      fscanf(fp,”%f”,&st[i].score[1]);
      fscanf(fp,”%f”,&st[i].score[2]);
      fscanf(fp,”%f”,&st[i].sum);
      fscanf(fp,”%f”,&st[i].averge); 
      if(feof(fp))break;
      stu++;
     }
    }

    void tc()
    {
     printf(“\n\n\n\n\n\n\n\n\t\t\t”);
     printf(“谢”);
     _sleep(200);
     printf(“谢”);
     _sleep(200);
     printf(“使”);
     _sleep(200);
     printf(“用”);
     _sleep(200);
     printf(“成”);
     _sleep(200);
     printf(“绩”);
     _sleep(200);
     printf(“管”);
     _sleep(200);
     printf(“理”);
     _sleep(200);
     printf(“系”);
     _sleep(200);
     printf(“统”);
     _sleep(200);
     printf(“\t\t   睿”);
     _sleep(200);
     printf(“水”);
     _sleep(200);
     printf(“汉\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n”);
     _sleep(200);
      exit(0); 
    }

  2. mcdz 说:

    这是我自己写的,可能只能实现部分功能!经供参考,自己修改

留下一个回复