| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 533 人关注过本帖
标题:学生档案管理系统 这个谁帮我改改
只看楼主 加入收藏
爱在天涯海角
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2011-10-20
结帖率:20%
收藏
已结贴  问题点数:15 回复次数:3 
学生档案管理系统 这个谁帮我改改
#include<stdio.h>
#include<stdlib.h>
#include <string.h>
#define  SIZE  100
struct stud_type
    {
     char num[3];
       char name[10];
    char sex;
    char date[10];
    char nation[4];
    char addr[15];
    char polaff[2];  
    int score;
    };
struct stud_type  arrange,student[SIZE];
 FILE *fp;
 char numstr[20];
 int  n=0;
 void menu();
 void LR();//录入
 void XG();//修改
 void ZJ();//增加
 void JS();//减少
 void SC();//删除
 void CZ();//查询
 void TJPJ();  //统计平均
 void TJNN();  //统计男女
 void TJMN();  //统计某年以前出生人数
 void TJCSD();  //统计出生地
 void TJZZ();  //统计政治面貌  
 void XS();//显示
 void XSGR();//显示个人
 void XSQB();//显示全部
 void main()
{
 menu();
}
                  /***************菜单()**************/
void menu()
{
char choice;
printf("-----------------------------------------------------------\n");
printf("||           ~~~***学生统计管理***~~~                    ||\n");
printf("===========================================================\n");
printf("||1.信息录入       2.信息修改     3.信息增加   4.信息减少||\n");
printf("||5.信息删除       6.信息查询     7.统计平均数           ||\n");
printf("||8.统计男女人数   9.统计某年以前出生人数                ||\n");
printf("||10.统计出生地    11.统计政治面貌    12.显示            ||\n");
printf("||13.显示个人      14.显示全部     0.退出                ||\n");
printf("===========================================================\n");
printf("-------------------------------------------------==--------\n");
choice=getchar();getchar();
switch(choice)
   {
      case'1': LR(); break;
      case'2':XG(); break;
      case'3': ZJ(); break;
      case'4':JS(); break;
      case'5':SC(); break;
      case'6':CZ(); break;
      case'7':TJPJ(); break;
      case'8':TJNN(); break;
      case'9':TJMN(); break;
      case'10':TJCSD();break;
      case'11':TJZZ();break;
      case'12':XS();break;
      case'13':XSGR();break;
      case'14':XSQB();break;
      case'0':exit(0);
     }
menu();
}
        /*************输入信息 *************/
void function1()
{ char ch;
       n=0;
  if((fp=fopen("E:\学生统计管理.txt","wb"))==NULL)
  {
   printf("can't open file student.txt");
   exit(0);
  }
  printf("Please input a record:");
  for(n=0;n<=SIZE;)
      {
          printf("\n输入姓名第%d:记录\n:",n+1);
          gets(student[n].name);
          printf("\nenter numder:");
          gets(numstr);
          student[n].num=atol(numstr);
          printf("\n输入性别:");
          gets(numstr);
          student[n].age=atoi(numstr);
          printf("\nenter sex:");
          student[n].sex=getchar();getchar();
          printf("\nenter stu_class:");
          gets(student[n].stu_class);
          printf("\nenter Chinese score:");
          gets(numstr);
          student[n].C=atof(numstr);
          printf("\nenter Maths score:");
          gets(numstr);
          student[n].M=atof(numstr);
          printf("\nenter English score:");
          gets(numstr);
          student[n].E=atof(numstr);
          printf("\nenter Sports score:");
          gets(numstr);
          student[n].S=atof(numstr);
          n++;
      printf("have another record (y/n)\n");
      ch=getchar();getchar();
      if(ch=='n')
      break;
       }
 fwrite(student,sizeof(student[0]),n,fp);
 fclose(fp);
}

          /**********put out the imformation**********/
void function2()
 {  n=0;

    if((fp=fopen("student.txt","rb"))==NULL)
     {
      printf("can't open the file student.txt");
      exit(0);
     }
  printf("-Name Number Age Sex stu_class Chinese Maths English Sports-\n");
  while(fread(&student[n],sizeof(student[n]),1,fp)==1)
  {
    printf("%-6s%5ld%5d%5c%10s %8.1f%8.1f%8.1f%8.1f\n",
student[n].name,student[n].num,student[n].age,
student[n].sex,student[n].stu_class,student[n].C,
student[n].M,student[n].E,student[n].S);
    n++;
  }
  fclose(fp);
 }
                 /***********Search the imformation***********/
 void function3()
 {
  int a=0; char ch; n=0;
  if((fp=fopen("student.txt","rb"))==NULL)
    {
       printf("can not open the file.\n ");
       exit(0);
    }
   while(fread(&student[n],sizeof(student[n]),1,fp)==1)
   n++;
   a=n;
    printf("which way do you want to search by?\n");
    printf("1.name 2.number 3.stu_class\n");
    ch=getchar();getchar();
    switch(ch)
    {
   case '1':
     printf(" Please input the record's name you want to search:\n");
     gets(numstr);
     for(n=0;n<a;)
      {
        if(!strcmp(numstr,student[n].name))
        break;
         n++;
     }
     break;
   case '2':
     printf("Please input the record's number you want to search\n");
     gets(numstr);
     for(n=0;n<a;)
      {
       if(atol(numstr)==student[n].num)
       break;
       n++;
      }
     break;
    case '3':
     printf("Please input the record's stu_class you want to search\n");
     gets(numstr);
     for(n=0;n<a;)
      {
       if(!strcmp(numstr,student[n].stu_class))
       break;
       n++;
      }
     break;
    }
 printf("-Name Number Age Sex stu_class Chinese  Maths English Sports-\n");
 printf("%-6s%5ld%5d%5c%10s %8.1f%8.1f%8.1f%8.1f\n",
student[n].name,student[n].num,student[n].age,
student[n].sex,student[n].stu_class,student[n].C,
student[n].M,student[n].E,student[n].S);
    fclose(fp);
 }
        /**********Modify the imformation*********/
void function4()
{ char ch;int i;
  printf("which record do you want to modify? you must search first\n");
  function3();
  i=0;
   if((fp=fopen("student.txt","rb+"))==NULL)
    {
       printf("can not open the file.\n ");
       exit(0);
    }
  while(fread(&student[i],sizeof(student[i]),1,fp)==1)
  i++;
  printf("where you want to modify?\n");
  printf("1.Name2.Number3.Age4.Sex5.stu_class6. ");
printf("6.Chinese7.Maths8.English9.Sports\n");
  ch=getchar();getchar();
  switch(ch)
   {
    case '1':printf("please input the new name.\n");
gets(student[n].name);
               printf("%s\n",student[n].name);
break;
    case '2':
printf("please input the new number.\n");
gets(numstr);
student[n].num=atol(numstr);
break;
    case '3':
printf("please input the new age.\n");
gets(numstr);
student[n].age=atoi(numstr);
break;
    case '4':
printf("please input the new sex.\n");
student[n].sex=getchar();
getchar();
break;
    case '5':
printf("please input the new stu_class.\n");
gets(student[n].stu_class);
break;
    case '6':
printf("please input the new chinses score.\n");
gets(numstr);
student[n].C=atof(numstr);
break;
    case '7':
printf("please input the new math score.\n");
 gets(numstr);
student[n].M=atof(numstr);
break;
    case '8':
printf("please input the new english score.\n");
gets(numstr);
student[n].E=atof(numstr);
break;
    case '9':
printf("please input the new sports score.\n");
 gets(numstr);
student[n].S=atof(numstr);
break;
  }
  printf("%-6s  %5ld  %5d %5c %10s %8.1f%8.1f%8.1f%8.1f\n",
student[n].name,student[n].num,student[n].age,
student[n].sex,student[n].stu_class,student[n].C,
student[n].M,student[n].E,student[n].S);
  rewind(fp);
  fwrite(student,sizeof(student[0]),i,fp);
  fclose(fp);
}
/***********Inseart the imformation ************/
void function5()
{
 int i;int a=0;
printf("if you want to insert record. ");
printf("please search the record insert before.\n");
 function3();
 i=0;
  if((fp=fopen("student.txt","rb+"))==NULL)
     {
      printf("can't open the file student.txt");
      exit(0);
     }
   while (fread(&student[i],sizeof(student[0]),1,fp)==1)
          i++;
   a=i;
   for(i=a-1;i>n-1;i--)
       student[i+1]=student[i];
   printf("\nenter name:");
gets(student[n].name);
   printf("enter number:");
   gets(numstr);
student[n].num=atol(numstr);
   printf("\nenter age:");
   gets(numstr);
student[n].age=atoi(numstr);
   printf("\nenter sex:");
student[n].sex=getchar();getchar();
   printf("\nenter stu_class:");
gets(student[n].stu_class);
   printf("\nenterChinese score:");
   gets(numstr);
student[n].C=atof(numstr);
   printf("\nenter Maths score:");
   gets(numstr);
student[n].M=atof(numstr);
   printf("\nenter English score:");
   gets(numstr);
student[n].E=atof(numstr);
   printf("\nenter Sports score:");
   gets(numstr);
student[n].S=atof(numstr);
  rewind(fp);
  fwrite(student,sizeof(student[0]),a+1,fp);
  fclose(fp);
}
                    /****************Delete the information****************/
void function6()
{
  int i=0;int a=0;
printf("if you want to delete ** record.you must search first.\n");
  function3();
  if((fp=fopen("student.txt","rb+"))==NULL)
     {
      printf("can't open the file student.txt");
      exit(0);
     }
   while (fread(&student[n],sizeof(student[0]),1,fp)==1)
          i++;
          a=i;
   for(i=n;i<a;i++)
  student[i]=student[i+1];
  fp=fopen("student.txt","wb");
  fwrite(student,sizeof(student[0]),a-1,fp);
  fclose(fp);
}
         /***********Work the total or average**********/
 void function7()
 {
  int i=0;int a=0;double sum=0;char ch;
  if((fp=fopen("student.txt","rb"))==NULL)
     {
      printf("can't open the file student.txt");
      exit(0);
     }
   while (fread(&student[n],sizeof(student[0]),1,fp)==1)
          i++;
          a=i;
printf("1.one's average 2.one's total 3.total");
printf("4.every course average score \n");
  ch=getchar();getchar();
  switch(ch)
  {
  case '1':
printf("whose average score,please search first.\n");
function3();
        sum=student[n].C+student[n].M+student[n].E+student[n].S;
        printf("%s\'s average score is %f",student[n].name,sum/4);
break;
  case '2':  
printf("whose total score ,please search first.\n");
function3();
         sum=student[n].C+student[n].M+student[n].E+student[n].S;
         printf("%s\'s total is %f\n",student[n].name,sum);
break;
  case '3':
for(i=0;i<a;i++)
         sum=sum+student[i].C+student[i].M+student[i].E+student[i].S;
         printf("total is %f\n",sum);
break;
  case '4':
printf("which course\'s average score?\n");
         printf("1.chinese2.math 3.english 4.sports\n");
         switch(ch)
            {
            case '1':for(i=0;i<a;i++)
                        sum=sum+student[i].C;
                     printf("chinese's average is %f\n",sum/a);break;
            case '2': for(i=0;i<a;i++)
                     sum=sum+student[i].M;
                        printf("math's average is %f\n",sum/a);break;
            case '3': for(i=0;i<a;i++)
                     sum=sum+student[i].E;
                        printf("english's average is %f\n",sum/a);break;
            case '4': for(i=0;i<a;i++)
                     sum=sum+student[i].S;
                        printf("sport's average is %f\n",sum/a);break;
            }
  }
  fclose(fp);
 }
                /***********Sort by three ways************/
 void function8()
 {
   char ch;
   int i=0;int a=0,m=0,k=0;
   if((fp=fopen("student.txt","rb+"))==NULL)
     {
      printf("can't open the file student.txt");
      exit(0);
     }
   while (fread(&student[n],sizeof(student[0]),1,fp)==1)
          i++;
          a=i;
  printf("which way do you want to sort in?\n");
  printf("1.number 2.score\n");
  ch=getchar();getchar();
  switch(ch)
  {
    case '1': for(i=0;i<a-1;i++)
                for(k=i+1;k<a;k++)
                   if(student[i].num>student[k].num)
                   {
                         arrange=student[k];
                            student[k]=student[i];
                         student[i]=arrange;
                        }
               break;
    case '2':
printf("sort in?1.chinese score 2.math score
3.english score 4.sports score\n");
            ch=getchar();getchar();
            switch(ch)
            {
              case '1': for(i=0;i<a-1;i++)
                           for(k=i+1;k<a;k++)
                          if(student[i].C>student[k].C)
                          {
                            arrange=student[k];
                            student[k]=student[i];
                            student[i]=arrange;
                          }
                         break;
             case '2': for(i=0;i<a-1;i++)
                         for(k=i+1;k<a;k++)
                         if(student[i].M>student[k].M)
                         {
                         arrange=student[k];
                         student[k]=student[i];
                         student[i]=arrange;
                          }
                         break;
             case '3': for(i=0;i<a-1;i++)
                          for(k=i+1;k<a;k++)
                         if(student[i].E>student[k].E)
                        {
                         arrange=student[k];
                         student[k]=student[i];
                         student[i]=arrange;
                         }
                          break;
             case '4':for(i=0;i<a-1;i++)
                        for(k=i+1;k<a;k++)
                        if(student[i].S>student[k].S)
                         {
                           arrange=student[k];
                          student[k]=student[i];
                          student[i]=arrange;
                          }
                          break;
           }
            break;
}
rewind(fp);
fwrite(student,sizeof(student[0]),a,fp);
fclose(fp);
}
/********************Append a record***********************/
void function9()
{
 n=0;
    if((fp=fopen("student.txt","ab"))==NULL)
   { printf("can't open student.txt file\n");
    exit(0);
   }
  while (fread(&student[n],sizeof(student[0]),1,fp)==1)
          n++;
          fclose(fp);
  if((fp=fopen("student.txt","ab"))==NULL)
   {
    exit(0);
   }
   printf("\nenter name:");
   gets(student[n].name);
   printf("enter number:");
   gets(numstr);
   student[n].num=atol(numstr);
   printf("\nenter age:");
   gets(numstr);
   student[n].age=atoi(numstr);
   printf("\nenter sex:");
   student[n].sex=getchar();getchar();
   printf("\nenter stu_class:");
   gets(student[n].stu_class);
   printf("\nenterChinese score:");
   gets(numstr);
   student[n].C=atof(numstr);
   printf("\nenter Maths score:");
   gets(numstr);
   student[n].M=atof(numstr);
   printf("\nenter English score:");
   gets(numstr);
   student[n].E=atof(numstr);
   printf("\nenter Sports score:");
   gets(numstr);
   student[n].S=atof(numstr);
   fwrite(&student[n],sizeof(student[n]),1,fp);
   fclose(fp);
}
搜索更多相关主题的帖子: 录入 统计 档案管理 include nation 
2011-12-25 19:30
爱在天涯海角
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2011-10-20
收藏
得分:0 
大家帮帮忙吧  急用的谁能来改改呀  最好提示编号什么的用中文书写进去



[ 本帖最后由 爱在天涯海角 于 2011-12-25 19:37 编辑 ]
2011-12-25 19:35
Timmmy
Rank: 2
等 级:论坛游民
帖 子:20
专家分:33
注 册:2011-11-5
收藏
得分:15 
回复 2楼 爱在天涯海角
不是你写的?
2011-12-25 19:37
爱在天涯海角
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2011-10-20
收藏
得分:0 
有错误  不会弄了  
帮帮忙呀
2011-12-25 19:41
快速回复:学生档案管理系统 这个谁帮我改改
数据加载中...
 
   



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

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