学⽣成绩管理系统-C 语⾔(附源码)
这是我初学C时的期末作业,贴出来。系统功能层次图
在这⾥插⼊图⽚描述
源代码//头⽂件#include <stdio.h>#include <string.h>#include <stdlib.h>#include <conio.h>//成绩结构体struct score { char snum [9]; char sname [11]; int chinese ; int math ; int english ; int sumcj ;//成绩总数 int rank ;//排名 };//函数声明 void showmenu (void );//菜单 int xg (int );//修改成绩 void lr (int );//录⼊成绩 void cx (int );//查询成绩 void xhcx (int );//学号查询 void xmcx (int n );//姓名查询void allrankcx (int );//排名查询 void showcxmenu (void );//⼆级菜单,查询菜单 void xs (int );//成绩显⽰ void jspm (int );//计算排名 int sc (int );//删除成绩 void bccj (void );//保存成绩并退出count函数是怎么创建的
1
2
3
4
5
6
7
8
9
10access是什么软件?
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
冒泡排序代码c语言27
28
29
30
31
int main (){ int flag ,n =0,count =0;//flag 标志位,count 计数,当前总⼈数 //-------------判断⽂件⾥⾯有多少条记录--------------------// FILE *fp ; fp =fopen ("cj.txt","a+"); if (fp ==NULL ) { printf ("打开⽂件失败,请重试!\n"); getch (); fclose (fp ); exit (0); } int c = 0; while (!feof (fp )) { char cc = fgetc (fp ); if (cc ==EOF ) { break ; } //输出字符// putchar(cc); c ++; } count = c /14;// printf("%d", count); // getch(); fclose (fp ); //---------------------------------// do { showmenu (); scanf ("%d",&flag );//选择操作 switch (flag ) { case 1: printf ("请输⼊您要录⼊的⼈数:"); scanf ("%d",&n ); lr (n ); count += n ;break ; case 2: count =sc (count );break ; case 3: xg (count );break ; case 4: cx (count );break ; case 5: jspm (count );break ; case 6: xs (count );break ; case 0: bccj ();break ; default :printf ("输⼊错误,请重试!\n");getch (); } }while (flag !=0); getch (); return 0;}go语法基础知识
234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
void showmenu (){ system ("cls"); printf ("*----------------------------------------------------*\n"); printf ("* 欢迎使⽤**成绩管理系统 *\n"); printf ("*----------------------------------------------------*\n"); printf ("* 1: 录⼊成绩 *\n"); printf ("* 2: 删除成绩 *\n"); printf ("* 3: 修改成绩 *\n"); printf ("* 4: 成绩查询 *\n"); printf ("* 5: 成绩计算并排名 *\n"); printf ("* 6: 显⽰成绩信息 *\n"); printf ("* 0: 保存信息并退出系统 *\n"); printf ("*----------------------------------------------------*\n"); printf ("选择操作<0-6> \n"); return ;}
jealousvue成熟maoffhands翻译23456789101112131415161718
void lr (int n ) { struct score stu [100]; FILE *fp ; fp =fopen ("cj.txt","a+"); if (fp ==NULL ) { printf ("打开⽂件失败,请重试!\n"); getch (); fclose (fp ); exit (0); } printf ("请输⼊全部学⽣的学号,姓名,语⽂成绩,数学成绩,英语成绩;\n"); int i ; for (i =0;i <n ;i ++) { printf ("----第%d 个学⽣----\n", i +1); printf ("学号:"); scanf ("%s",&stu [i ].snum ); printf ("姓名:"); scanf ("%s,",&stu [i ].sname ); printf ("语⽂成绩:"); scanf ("%d",&stu [i ].chinese ); printf ("数学成绩:"); scanf ("%d",&stu [i ].math ); printf ("英语成绩:"); scanf ("%d",&stu [i ].english ); stu [i ].sumcj =0; stu [i ]
.rank =0; //写⼊数据 fprintf (fp ,"%s %s %d %d %d %d %d\n",stu [i ].snum ,stu [i ].sname ,stu [i ].chinese ,stu [i ].math ,stu [i ].english ,stu [i ].sumcj ,stu [i ].rank );} fclose (fp ); printf ("添加学⽣成功,请按任意键返回\n"); getch (); }234567891011121314151617181920212223242526272829303132333435363738394041//2删除成绩 int sc (int n ){ struct score stu [100]; struct score sub [99];//删除后的结构体数组 char stnum [9];//学号 int find =0; printf ("请输⼊你要删除的学⽣学号:"); scanf ("%s", &stnum ); FILE *fp ; fp =fopen ("cj.txt","r"); if (fp ==NULL ) { printf ("打开⽂件失败,请联系管理员\n"); getch (); return -1; } int c =0; int index =0;//⽤于记录⽬标序号 while (!feof (fp ))//不为空
1234567891011121314151617181920
while (!feof (fp ))//不为空 { fscanf (fp ,"%s %s %d %d %d %d %d\n", &stu [c ].snum ,&stu [c ].sname ,&stu [c ].chinese ,&stu [c ].math ,&stu [c ].english ,&stu [c ].sumcj ,&stu [c ].rank ); if (strcmp (stnum ,stu [c ].snum )==0) { find = 1;//根据学号查,到赋值为1 index = c ;//记录编号 } c ++; } fclose (fp ); if (n ==0) { printf ("已经没有学⽣成绩信息了,请按任意键返回\n"); getch (); showmenu (); return n ; } if (find ==0) { printf ("没有该学⽣成绩信息,请按任意键返回\n"); getch (); showmenu (); return n ; } else { int i ; //删除 for (i =0;i <c ;i ++) { if (i < index ) { sub [i ] = stu [i ]; } else { sub [i ] = stu [i +1]; } } fp =fopen ("cj.txt","w"); //写⼊数据 for (i =0;i <c -1;i ++) { fprintf (fp ,"%s
%s %d %d %d %d %d\n",sub [i ].snum ,sub [i ].sname ,sub [i ].chinese ,sub [i ].math ,sub [i ].english ,sub [i ].sumcj ,sub [i ].rank ); } fclose (fp ); printf ("学号为%s 的学⽣成绩删除成功,请按任意键返回\n",stnum ); getch (); showmenu (); return n -1; } }202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论