📄 studentresultsmanagementsystem.txt
字号:
#include<stdlib.h>
#include<stdio.h>
#include<graphics.h>
#include<dos.h>
#include<conio.h>
#include<string.h>
#define NULL 0
#define M 100 /*restore M student's information*/
#define N 100 /*restore N kinds of result*/
/*this two define is complant to change*/
struct student
{long num;
char name[10];
float score[N];
};
void myfun();
void myprint();
void fengmian();
void luru(struct student s[]);
void outinfor(struct student s[]);
void display(struct student s[],int m);
int mysearch(struct student *s,long n);
void delete(struct student s[],long m);
void change(struct student s[],long m);
void reserve(struct student s[],int m);
long x;
int j,i,k,t,a;
static int r=0,b;
char choose,yesno,C;
struct student abc[M];
main()
{ textcolor(4);
textbackground(15);
fengmian();
printf("\nHello! Welcome to exame\n");
printf("\nEnter or not?(y/n): ");
scanf("%c",&yesno);
switch(yesno)
{ case 'Y':
case 'y':myfun();
break;
default:
clrscr();
printf(" \n\n\n\n\n\n\n");
printf("\t\t**************Thank you for looking!**************");
printf("\n\n\n\n\n\n\n");
printf("\t\t**************Welcome to next time!****************");
break;
}
}
void myprint() /*out menu*/
{ clrscr();
printf("\n\n\n");
printf("\t|****************************************************|\n");
printf("\t| choose the function (0~4): |\n");
printf("\t|****************************************************|\n");
printf("\t| 1--find information |\n");
printf("\t| 2--delete information |\n");
printf("\t| 3--change information |\n");
printf("\t| 4--reserve information |\n");
printf("\t| 0--exit |\n");
printf("\t|****************************************************|\n");
}
int mysearch(struct student *s,long n) /*change information*/
{ int i;
for(i=0;i<r;i++)
if(s[i].num==n)
break;
if(i<r)
return i;
else
return -1;
}
void myfun()
{
printf("\ncreate information before comming in!\n");
luru(abc);
if(yesno=='Y'||yesno=='y')
{
do
{
myprint();
printf("\n\n Please choose sevice(0~4) :");
choose=getch();
printf("\n\nYou chooce is %c \n",choose);
switch(choose)
{case '1':outinfor(abc); /*display all information and find record*/
break;
case '2':printf("\nPlease input the delete number of the student\n");
scanf("%ld",&x); /*delete information*/
while(x<0) /*deal with mistake*/
{
printf("inputing is wrong,rewrite it!\n");
scanf("%ld",&x);
}
delete(abc,x);
break;
case '3':printf("Please input the change number of the student:\n");
scanf("%ld",&x); /*change information*/
while(x<0) /*deal with mistake*/
{
printf("inputing is wrong,rewrite it!\n");
scanf("%ld",&x);
}
change(abc,x);
break;
case '4':reserve(abc,r);
break;
case '0':clrscr();
printf("\n\n\n\t\tThank you for looking!\n");
break;
default:printf("\nsorry! %c is a wrong choose!\n",choose);
}
if(choose=='0')
break;
printf("\n continue it or not?(Y/N)\n");
do
{ yesno=getch();
}while(yesno!='y'&&yesno!='Y'&&yesno!='n'&&yesno!='N');
}while(yesno=='y'||yesno=='Y');
clrscr();
printf("\n\n\n\n\n\n");
printf("\t\tThank you for your using!");
printf("\n\n\n");
printf("\t\t\tGoodbye!");
}
}
void display(struct student s[],int m) /*out all of information*/
{ int i,j,flag=0;
printf("--------------------------------------------------------------------\n");
for(i=0;i<m;i++)
{
if(flag==0)
{ printf("num name score\n");
printf("------------------------------------------------------------------\n");
}
printf("%-17ld",s[i].num);
printf("%-22s",s[i].name);
for(j=0;j<b;j++)
printf("%.1f\t",s[i].score[j]);
printf("\n");
flag=1;
delay(10);
}
printf("-------------------------------------------------------------------\n");
}
void reserve(struct student s[],int m) /*reserve information*/
{ FILE *sfp,*fp;
int i,j,flag=0;
sfp=fopen("d:\\dfile.txt","w");
if(sfp==NULL)
{printf("Destination dile not opened\n");
exit(0);
}
for(i=0;i<m;i++)
{fprintf(sfp,"%ld %s ",s[i].num,s[i].name);
for(j=0;j<b;j++)
fprintf(sfp,"%.1f ",s[i].score[j]);
fprintf(sfp,"\n");
}
fclose(sfp);
fp=fopen("d:\\dfile.txt","r");
if(fp==NULL)
{printf("Destination dile not opened\n");
exit(0);
}
for(i=0;i<m;i++)
{fscanf(fp,"%ld %c ",&s[i].num,s[i].name);
for(j=0;j<b;j++)
fscanf(fp,"%.1f ",&s[i].score[j]);
}
fclose(fp);
printf("\nyou information have been reserved!\n");
printf("\nThis is your all information after reserve:"); /*out after reserve all information*/
printf("\n\n");
for(i=0;i<m;i++)
{if(flag==0)
printf("num name score\n");
printf("%-17ld",s[i].num);
printf("%-22s",s[i].name);
for(j=0;j<b;j++)
printf("%.1f\t",s[i].score[j]);
putchar('\n');
flag=1;
delay(30);
}
}
void delete(struct student s[],long m) /*delete information*/
{int i,j;
char w;
for(i=0;i<r;i++)
if(s[i].num==m)
break;
if(i<r)
{
printf("\nAre you sure delete the information(y/n)?\n");
do{
w=getch();
}while(w!='Y'&&w!='y'&&w!='n'&&w!='N');
if(w=='Y'||w=='y')
{for(j=0;j<b&&i<r-1;j++)
{ s[i].num=s[i+1].num;
strcpy(s[i].name,s[i+1].name);
s[i].score[j]=s[i+1].score[j];
}
r--;
printf("\n\nThe student's information have been deleted!\n");
}
else
printf("\n\nthe student's information haven't been deleted!\n");
}
else
printf("The student not exit!\n");
}
void change(struct student s[],long m) /*change information*/
{int i,j,find;
long tempnum;
char tempname[10],c,T[90];
float tempscore[N];
for(i=0;i<r;i++)
if(s[i].num==m)
{
find=i;
break;
}
if(i==r) /*out at normal*/
printf("wu ci ren \n");
else
{printf("The student's information is:\n");
printf("num:%ld\n",s[find].num);
printf("name:%s\n",s[find].name);
printf("Every results is:\n");
for(j=0;j<b;j++)
{printf("score %d:",j+1);
printf("%.1f\n",s[find].score[j]);
}
do
{ printf("\nPlease input the right num:\n");
scanf("%ld",&tempnum);
while(tempnum<0) /*deal with mistake*/
{ printf("inputting is wrong,rewrite it!\n");
scanf("%d",&tempnum);
}
printf("Please input the right name:\n");
gets(T);
gets(tempname);
printf("Please input the right result(0~100):\n");
for(j=0;j<b;j++)
{ printf("score %d:",j+1);
scanf("%f",&tempscore[j]);
}
for(i=0;i<r;i++)
if((s[i].num==tempnum)&&i!=find)
{ printf("\nThe num have exited,do you want to input the other num(y/n)?\n");
do
{ c=getche();
}while(c!='y'&&c!='Y'&&c!='n'&&c!='N');
putchar('\n');
break;
}
if(i==r) /* find is the place you want to change*/
{ s[find].num=tempnum;
strcpy(s[find].name,tempname);
for(j=0;j<b;j++)
s[find].score[j]=tempscore[j];
}
}while(c=='y'||c=='Y');
}
}
void luru(struct student s[]) /*input information */
{int i,j;
char T[90];
printf("\nPlease input the number of the students you want to save:");
scanf("%d",&a);
printf("\nPlease input the number of the results you want to save:");
scanf("%d",&b);
for(i=0;i<a;i++)
{ printf("\nNumber %d :",i+1);
scanf("%ld",&s[i].num);
while((s[i].num)<0) /*deal with mistake*/
{
printf("inputing is wrong,rewrite it!\n");
scanf("%ld",&s[i].num);
}
printf("name:");
gets(T);
gets(s[i].name);
printf("%d kinds of result(0~100):\n",a);
for(j=0;j<b;j++)
{ printf("score %d:",j+1);
scanf("%f",&s[i].score[j]);
}
r++;
}
printf(" \n\nThe information have been finshed!\n ");
printf("\nwhether into it or not?(Y/N)\n");
yesno=getch();
printf("\n");
}
void outinfor(struct student s[]) /*display all information and find record*/
{ int k,i,j;
long x;
float average,sum=0;
printf("\nPlease input the find number of the student:\n");
scanf("%ld",&x);
printf("\nAll the student's information is:\n");
display(s,r);
while(x<0) /*deal with mistake*/
{ printf("Inputting is wrong,rewrite it!\n");
scanf("%ld",&x);
}
k=mysearch(s,x);
if(k!=-1)
{ printf("\nthe student's information that you find is:\n");
printf("num:%ld\n",s[k].num);
printf("name:%s\n",s[k].name);
printf("Every kinds of result is:\n");
for(j=0;j<b;j++)
{ printf("score %d:",j+1);
printf("%.1f\n",s[k].score[j]);
}
for(j=0;j<b;j++)
sum+=s[k].score[j];
average=(float)sum/b;
printf("average=%.1f\n",average);
}
else
printf("\nHaven't look up the student whose number is %ld!\n",x);
}
void fengmian() /*out face of the excise*/
{
printf("\n\n\n\n\n");
printf("|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|\n");
printf("| students result administration system |\n");
printf("| school:South-Central university For Nationalities |\n");
printf("| name:Li Yanqun |\n");
printf("| num:05061035 |\n");
printf("| major:computer |\n");
printf("| grade:2005 |\n");
printf("| class:two |\n");
printf("| director teacher:Zeng Guangping |\n");
printf("|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|\n");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -