加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 创业 > C语言 > 正文

C语言实现学生学籍管理系统

发布时间:2020-12-15 01:04:24 所属栏目:C语言 来源:网络整理
导读:本文实例为大家分享了C语言实现学生学籍管理系统的具体代码,供大家参考,具体内容如下 #includestdio.h #includeconio.h #includestdlib.h #includestring.h #includewindows.h //**********************************结构体*******************************

本文实例为大家分享了C语言实现学生学籍管理系统的具体代码,供大家参考,具体内容如下

#include<stdio.h> 
#include<conio.h> 
#include<stdlib.h> 
#include<string.h> 
#include<windows.h> 
 
 
//**********************************结构体************************************* 
struct score 
{ 
 char class_num[10]; 
 char person_num[10]; 
 char name[15]; 
 char sex; 
 int num; 
}stu; 


//******************************输出******************************************* 
void print1()            //输出科目函数 
{ 
printf("班级  学号  姓名    性别  分数n"); 
} 

//*****************************菜单******************************************** 
int menu()             //菜单函数 
{ 
 
 char i; 
 printf("nnnn"); 
 puts("tt**********************主菜单******************tn"); 
 puts("tttt1.学生信息输入        n"); 
 puts("tttt2.学生信息浏览        n"); 
 puts("tttt3.学生信息检索        n"); 
 puts("tttt4.学生信息修改        n"); 
 puts("tttt5.学生信息删除        n"); 
 puts("tttt6. 退 出 系 统        n"); 
 puts("tt**********************************************tn"); 
 printf("ttt 请选择(1-6):[ ]bb"); 
 i=getchar(); 
 system("cls"); 
 return i; 
} 

//**********************输入函数******************************************* 
void Enter() 
{ 
 
 FILE *fp; 
 char ch; 
 if((fp=fopen("f:zimou.txt","a+"))==NULL) 
 { 
  printf("nCannot open file!n"); 
  getch(); 
  exit(1); 
 } 
 do 
 { 
  printf("请输入班级:");scanf("%s",stu.class_num);getchar(); 
  printf("n"); 
  printf("请输入学号:");gets(stu.person_num); 
  printf("n"); 
  printf("请输入姓名:");gets(stu.name); 
  printf("n"); 
  printf("性  别(m/f):");scanf("%c",&stu.sex);getchar(); 
  printf("n"); 
  printf("分  数:");scanf("%d",&stu.num);getchar(); 
  printf("n"); 
  fwrite(&stu,sizeof(stu),1,fp); 
  printf("继续(y/n)?[ ]bb"); 
  ch=getchar(); getchar(); 
 }while(ch=='y'||ch=='Y'); 
 fclose(fp); 
 system("cls"); 
} 
 
 
 
//*****************浏览函数********************************************** 
void Browse() 
{ 
 
FILE *fp; 
int total=0; 
if((fp=fopen("f:zimou.txt","a+"))==NULL) 
{ 
 printf("tCan not open the inform file!"); 
 getch(); 
 exit(1); 
} 
while(fread(&stu,fp)==1) 
{ 
 total++; 
 if(total==1) 
 print1(); 
 printf("%-10s%-10s%-20s",stu.class_num,stu.person_num,stu.name); 
 printf("%-8c",stu.sex); 
 printf("%-4d ",stu.num); 
 printf("n"); 
} 
fclose(fp); 
printf("nnt共有 %d 条记录!n",total); 
printf("tpress any key to continue!"); 
getchar(); 
getchar(); 
system("cls"); 
 
} 
 
 
//*******************查询函数********************************************* 
void Query() 
{ 
 FILE * fp; 
 char num1[10]; 
 char ch; 
if((fp=fopen("f:zimou.txt","a+"))==NULL) 
{ 
 printf("tCan not open the inform file!"); 
 getch(); 
 exit(1); 
} 
do 
{ 
 getchar(); 
 rewind(fp); 
 printf("n请输入学号查询:"); 
 gets(num1); 
 while(fread(&stu,fp)==1) 
  if(strcmp(num1,stu.person_num)==0) 
  { 
   print1(); 
   printf("%-10s%-10s%-20s",stu.name); 
   printf("%-8c",stu.sex); 
   printf("%-4d ",stu.num); 
   printf("n"); 
   break; 
  } 
  puts("n"); 
 printf("继续查询?(Y/N):[ ]bb"); 
 ch=getchar(); 
}while(ch=='Y'||ch=='y'); 
fclose(fp); 
system("cls"); 
} 
 
 
//**********************学生成绩修改函数*********************************** 
 
void Recopose() 
{ 
  FILE * fp1,* fp2; 
  char num1[10]; 
  char ch; 
  getchar(); 
 do 
 { 
  if((fp1=fopen("f:zimou.txt","a+"))==NULL) 
  { 
  printf("tCan not open the infom file!"); 
  getch(); 
  exit(1); 
  } 
  if((fp2=fopen("f:ziye.txt","a+"))==NULL) 
  { 
  printf("tCan not creat the temp file!"); 
  getch(); 
  exit(1); 
  } 
  printf("请输入想要修改的学号:"); 
  gets(num1); 
while(fread(&stu,fp1)==1) 
{ 
  if(strcmp(num1,stu.num); 
   printf("n"); 
   printf("nnPlease input the new information:n"); 
   printf("t班级代号:");gets(stu.class_num); 
   printf("t学生学号:");gets(stu.person_num); 
   printf("t学生姓名:"); gets(stu.name); 
   printf("t学生性别:");gets(&stu.sex); 
   printf("t学生成绩:");scanf("%d",&stu.num); getchar(); 
  } 
 fwrite(&stu,fp2); 
 } 
 fclose(fp1); 
 fclose(fp2); 
 printf("修改成功!n"); 
 remove("f:zimou.txt"); 
 rename("f:ziye.txt","f:zimou.txt"); 
 printf("继续修改?(Y/N):[ ]bb"); 
 ch=getchar(); getchar(); 
}while(ch=='Y'||ch=='y'); 
 system("cls"); 
} 
 
 
//*********************删除函数****************************************** 
void Delete() 
{ 
  FILE * fp1,* fp2; 
  int flag; 
  char num1[10]; 
  char ch; 
  getchar(); 
  do 
  { 
  if((fp1=fopen("f:zimou.txt","a+"))==NULL) 
  { 
   printf("tCan not open the inform file!"); 
   getch(); 
   exit(1); 
  } 
  if((fp2=fopen("f:ziye.txt","a+"))==NULL) 
  { 
   printf("tCan not creat the temp file!"); 
   getch(); 
   exit(1); 
  } 
  printf("请输入你要删除的学生的学号:"); 
  gets(num1); 
  flag=0; 
  while(fread(&stu,fp1)==1) 
  { 
   if(strcmp(num1,stu.person_num)==0) 
   { 
    print1(); 
    printf("%-10s%-10s%-20s",stu.name); 
    printf("%-8c",stu.sex); 
    printf("%-4d ",stu.num); 
    printf("n"); 
    flag=1; 
   } 
   else 
    fwrite(&stu,fp2); 
  } 
  fclose(fp1); 
  fclose(fp2); 
  if(flag==1) 
  { 
   remove("f:zimou.txt"); 
   rename("f:ziye.txt","f:zimou.txt"); 
  } 
  else 
   printf("Can not find this record!n"); 
  printf("继续删除?(Y/N):[ ]bb"); 
  ch=getchar(); getchar(); 
  }while(ch=='Y'||ch=='y'); 
  system("cls"); 
} 
 
 
//***********************************退出************************************** 
void Exit() 
{ 
 puts("ntttt感谢使用本系统!!nntttt有任何问题请联系:1005483758@qq.com n"); 
 exit(0); 
} 
 
//******************欢迎界面********************************** 
void Welcome() 
{ 
  printf("nn"); 
 printf(" t┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓n"); 
 printf(" t┃**********************************************************┃n"); 
 printf(" t┃***┏━━━━━━━━━━━━━━━━━━━━━━━━┓***┃n"); 
 printf(" t┃***┃************************************************┃***┃n"); 
 printf(" t┃***┃***           ****┃***┃n"); 
 printf(" t┃***┃***  欢迎使用学生成绩管理系统   ****┃***┃n"); 
 printf(" t┃***┃***           ****┃***┃n"); 
 printf(" t┃***┃***           ****┃***┃n"); 
 printf(" t┃***┃***     制作人:XXY   ****┃***┃n"); 
 printf(" t┃***┃***           ****┃***┃n"); 
 printf(" t┃***┃***      2013.6.20  ****┃***┃n"); 
 printf(" t┃***┃***           ****┃***┃n"); 
 printf(" t┃***┃************************************************┃***┃n"); 
 printf(" t┃***┗━━━━━━━━━━━━━━━━━━━━━━━━┛***┃n"); 
 printf(" t┃**********************************************************┃n"); 
 printf(" t┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛n"); 
 puts(" nt      ① 管理员登陆!       n"); 
 puts(" nt      ② 游客 登陆!       n"); 
 printf("n请选择登陆(1 or 2):[ ]bb"); / /左移一位“b ” 
} 
 
//*****************************主函数**************************************** 
int main() 
{ 
  int i,k=0; 
  char username[15],pwd[7],c; 
  system("color 5e");//颜色 
  Welcome(); 
   c=getchar();getchar(); 
  if (c=='1') 
  { 
   system("cls");//跳转页面。 
   puts("nnnnnnntttt管 理 员 登 陆!nnnnntttt 请 登 陆!"); 
   getchar(); 
   for(i=0;i<3;i++) 
    { 
      printf("n请输入用户名:"); 
     gets(username); 
     printf("n请输入6位密码:"); 
     gets(pwd); 
     //判断条件 
     if((strcmp(username,"xiaxianyun")==0)&&(strcmp(pwd,"123456")==0)) 
     { 
      printf("n您已经成功登录n"); 
      k=1; 
      for(i=0;i<20;i++) 
      { 
        printf("."); 
        Sleep(100); 
      } 
     system("cls"); 
  
      while(1) 
      switch(menu()) 
      { 
       case '1':Enter();break; 
       case '2':Browse();break; 
       case '3':Query();break; 
       case '4':Recopose();break; 
       case '5':Delete();break; 
       case '6':Exit();break; 
      } 
      break; 
     } 
    else 
     printf("n用户名或密码无效 请重新输入:n"); 
     continue; 
    } 
     if(k==0) 
    printf("n连续输入错误3次 将退出程序n"); 
  Sleep(2000); 
  exit(1); 
  } 
  else if(c=='2')//游客登录 
  { 
   system("cls");//跳转页面。 
   puts("nnnnnnntttt欢 迎 游 客 进 入!nnnnntttt 请 确 定!"); 
   getchar(); 
   system("cls"); 
   while(1) 
    switch(menu()) 
    { 
     case '1':Enter();break; 
     case '2':Browse();break; 
     case '3':Query();break; 
     case '4':system("cls");getchar(); 
     puts("nntt对不起你没有权限修改!nn"); 
     printf("ttpress any key to continue!");getchar();system("cls");break; 
     case '5':system("cls");getchar(); 
     puts("nntt对不起你没有权限删除!nn"); 
     printf("ttpress any key to continue!");getchar();system("cls");break; 
     case '6':Exit();break; 
    } 
  }  
 return 0; 
} 

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程小技巧。

您可能感兴趣的文章:

  • C语言实现学生信息管理系统(单链表)
  • C语言单链表版学生信息管理系统
  • 学生信息管理系统C语言版
  • C语言实现简单学生学籍管理系统
  • C语言学生学籍管理系统课程设计
  • C语言实现图书管理系统
  • C语言实现歌曲信息管理系统
  • C语言职工信息管理系统源码
  • C语言银行系统课程设计
  • C语言银行储蓄系统源码

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读