C语言项目--教师信息/学生成绩管理系统

这个系统实现两个功能,分别是管理教师的信息和学生的成绩,用户可以选择切换实现相应的功能。话不多说了,现在看下程序的实现截图:
   这里给出程序代码下载地址:http://download.csdn.net/detail/dlutbrucezhang/5191828
  



  


  


  


  

   下面贴出部分代码:
   void add_tea(Teacher tea[]) 

int i=0,j,num; 
char str[5]; 
if(numtea!=0) 

  printf("cover the current record?(y/n)\n"); 
  gets(str); 
  if(str[0]=='Y'||str[0]=='y') 
   i=0; 
  else i=numtea; 


printf("Please input the number of you add the teachers:"); 
scanf("%d",&num); 
if(i==0) 
  numtea=num; 
else numtea+=num; 
if(numtea>lens) 

  lens+=10; 
  tea=(Teacher *)realloc(tea,lens*SIZE); 

printf("Please input the teacher's info:\n"); 
for(;i<numtea;i++) 

  getchar(); 
  printf("please input the teacher's NO.:"); 
  gets(tea .number); 
  printf("please input the teacher's name:"); 
  gets(tea.name); 
  printf("please input the teacher's sex(man/woman 0/1):"); 
  gets(tea.sex); 
  if(tea.sex[0]=='0') strcpy(tea.sex,"man"); 
  else strcpy(tea.sex,"woman"); 
  printf("please input the teacher's address:"); 
  gets(tea.addr); 
  printf("the teacher is married(No/Yes 0/1):"); 
  gets(tea.married); 
  if(tea.sex[0]=='0') strcpy(tea.sex,"No"); 
  else strcpy(tea.sex,"Yes"); 

display_tea(tea,0,numtea-1); 
getchar(); 
}
void display_tea(Teacher tea[],int n1,int n2) 

int i;
char str[2];
if(numtea==0){
        printf("There is Nothing!\n");
     printf("Do you want to open some file to find the record?(Y/N)\n");
     gets(str);
     if (str[0]=='Y'||str[0]=='y')
     {
      openfileTXT(tea);
     }
     else
     {
      return;
     }
}
else
{
  for(i=n1;i<=n2;i++) 
   printf("number:%s\tname:%s\t\tsex:%s\t\taddr:%s\t\tmarried:%s\t",tea.number,tea.name,tea.sex,tea.addr,tea.married);
}

void adjust(Teacher tea[]) 

char str[5]; 
int i=-1,j; 

if(numtea==0) 
{
  printf("there is nothing !!!\n"); 
  return;
}
while(i<0) 

  i=find_tea(tea); 
  if(i>=0) 
  { 
   printf("Delete it?(y/n)"); 
   gets(str); 
   if(str[0]=='y'||str[0]=='Y') 
   { 
    delete_tea(tea,i); 
    /*count(stud); */
   } 
   else 
   { 
    printf("Adjust it?(y/n)"); 
    gets(str); 
    if(str[0]=='y'||str[0]=='Y') 
    { 

     printf("Please input something you want:\n"); 
     printf("please input the teacher's NO.:"); 
     gets(tea.number); 
     printf("please input the teacher's name:"); 
     gets(tea.name); 
     printf("please input the teacher's sex(man/woman 0/1):"); 
     gets(tea.sex); 
     if(tea.sex[0]=='0') strcpy(tea.sex,"man"); 
     else strcpy(tea.sex,"woman"); 
     printf("please input the teacher's address:"); 
     gets(tea.addr); 
     printf("the teacher is married(No/Yes 0/1):"); 
     gets(tea.married); 
     if(tea.sex[0]=='0') strcpy(tea.sex,"No"); 
     else strcpy(tea.sex,"Yes"); 
    } 
    /*count(stud); */
   } 
   display_tea(tea,0,numtea-1); 
  } 
  printf("Again to Adjust it ?(y/n)\n"); 
  gets(str); 
  if(str[0]=='y'||str[0]=='Y') 
   i=-1; 
  else i=1; 



int find_tea(Teacher tea[]) 

char str[10]; 
int i; 
if(numtea==0) 

  printf("There is nothing\n"); 
  return -1; 

else 

  printf("what do you want your fashion ?\n1.number\t2.name\t3.addr\n"); 
  gets(str); 
  if(str[0]=='1') 
  { 
   printf("please input the teacher's number:"); 
   gets(str); 
   for(i=0;i<=numtea;i++) 
    if(strcmp(str,tea.number)==0) 
    { 
     display_tea(tea,i,i); 
     break; 
    } 
    else continue; 
  } 
  else if(str[0]=='2') 
  { 
   printf("please input the teacher's name:"); 
   gets(str); 
   for(i=0;i<=numtea;i++) 
    if(strcmp(str,tea.name)==0) 
    { 
     display_tea(tea,i,i); 
     break; 
    } 
    else continue; 
  } 
  else if(str[0]=='3') 
  { 
   printf("please input the teacher's address:"); 
   gets(str);
   for(i=0;i<=numtea;i++) 
    if(strcmp(str,tea.addr)==0) 
    { 
     display_tea(tea,i,i); 
     break; 
    } 
    else continue; 
  } 
  if(i>numtea) 
  { 
   printf("Nothing has find\n"); 
   return -1; 
  } 
  return i; 



void delete_tea(Teacher tea[],int i) 

int j; 
while(i>=0) 

  for(j=i;j<numtea;j++) 
   tea[j]=tea[j+1]; 
  numtea--; 
  printf("Delete Success!\n"); 



int writetoTXT(Teacher tea[]) 

int i=0,j; 
FILE *fp; 
char filename[20]; 
printf("Please input the file's name:"); 
gets(filename); 
fp=fopen(filename,"w"); 
fprintf(fp,"%d\n",numtea); 
while(i<numtea) 

  fprintf(fp,"%s %s %s %s %s",tea.number,tea.name,tea.sex,tea.addr,tea.married); 
  i++; 

fclose(fp); 
printf("Save success!!!\n"); 
display_tea(tea,0,numtea-1); 
numtea=0; 
return 0; 


int openfileTXT(Teacher tea[]) 

int i=0,j; 
FILE *fp; 
char filename[20],str[2]; 
if(numtea!=0) 

  printf("There has some records,Do you want to save them?(y/n)"); 
  gets(str); 
  if(str[0]=='y'||str[0]=='Y') 
   writetoTXT(tea); 

printf("Please input the file name:"); 
gets(filename); 
numtea=0; 
if((fp=fopen(filename,"rb+"))==NULL) 

  printf("Sorry ,can't open the file\n"); 
  return(-1); 

fscanf(fp,"%d",&numtea); 
fgetc(fp); 
while(i<numtea) 

  fscanf(fp,"%s",&tea.number); 
  fscanf(fp,"%s",&tea.name); 
  fscanf(fp,"%s",&tea.sex); 
  fscanf(fp,"%s",&tea.addr); 
  fscanf(fp,"%s",&tea.married); 
  i++; 

fclose(fp); 
printf("Read the file success\n"); 
printf("Display the record ?(y/n)"); 
gets(str); 
if(str[0]=='y'||str[0]=='Y') 
  display_tea(tea,0,numtea-1); 
return(0); 


void displayTheSystemInfo() 

printf("\t\t制作人员: \n\n"); 
printf("http://www.shengshiyouxi.com"); 
printf("\n\n"); 
}
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值