大佬教程收集整理的这篇文章主要介绍了C语言实现学生学籍管理系统,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
本文实例为大家分享了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("\n\n\n\n"); puts("\t\t**********************主菜单******************\t\n"); puts("\t\t\t\t1.学生信息输入 \n"); puts("\t\t\t\t2.学生信息浏览 \n"); puts("\t\t\t\t3.学生信息检索 \n"); puts("\t\t\t\t4.学生信息修改 \n"); puts("\t\t\t\t5.学生信息删除 \n"); puts("\t\t\t\t6. 退 出 系 统 \n"); puts("\t\t**********************************************\t\n"); printf("\t\t\t 请选择(1-6):[ ]\b\b"); 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)?[ ]\b\b"); ch=getchar(); getchar(); }while(ch=='y'||ch=='Y'); fclose(fp); system("cls"); } //*****************浏览函数********************************************** voID browse() { file *fp; int @R_587_10586@l=0; if((fp=fopen("f:\\zimou.txt","a+"))==NulL) { printf("\tCan not open the inform file!"); getch(); exit(1); } while(fread(&stu,fp)==1) { @R_587_10586@L++; if(@R_587_10586@l==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("\n\n\t共有 %d 条记录!\n",@R_587_10586@l); 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):[ ]\b\b"); 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("\n\nPlease 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):[ ]\b\b"); 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):[ ]\b\b"); ch=getchar(); getchar(); }while(ch=='Y'||ch=='y'); system("cls"); } //***********************************退出************************************** voID Exit() { puts("\n\t\t\t\t感谢使用本系统!!\n\n\t\t\t\t有任何问题请联系:1005483758@qq.com \n"); exit(0); } //******************欢迎界面********************************** voID Welcome() { printf("\n\n"); 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(" \n\t ① 管理员登陆! \n"); puts(" \n\t ② 游客 登陆! \n"); printf("\n请选择登陆(1 or 2):[ ]\b\b"); / /左移一位“\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("\n\n\n\n\n\n\n\t\t\t\t管 理 员 登 陆!\n\n\n\n\n\t\t\t\t 请 登 陆!"); 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("\n\n\n\n\n\n\n\t\t\t\t欢 迎 游 客 进 入!\n\n\n\n\n\t\t\t\t 请 确 定!"); 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("\n\n\t\t对不起你没有权限修改!\n\n"); printf("\t\tpress any key to conTinue!");getchar();system("cls");break; case '5':system("cls");getchar(); puts("\n\n\t\t对不起你没有权限删除!\n\n"); printf("\t\tpress any key to conTinue!");getchar();system("cls");break; case '6':Exit();break; } } return 0; }
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程小技巧。
以上是大佬教程为你收集整理的C语言实现学生学籍管理系统全部内容,希望文章能够帮你解决C语言实现学生学籍管理系统所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。