大家看看我的成绩管理。怎么就不行了呢?怎么了呢?
不能查询每个学生的数据了啊。看不出来。。。。。。脑子想大了。。这个文件:http://www.
代码:
#include <stdio.h>
#define C 40 //set line length
#define N 5 //set count of student
char name[N][10];
float mark[N][3];
char loading();
char line();
int input();
int search();
//----------------------------------------------------------------------------------
main()
{
int r; //o is choose of user,"r to recycle"
int o;
for(r=1;r<100;r++)
{ system("cls");
printf(" Main Menu\n");
line(C); /*output '*'*/
printf("* 1. input data\n* 2. search score\n* 3. exit\n"); /* show interface*/
line(C); /*output '*'*/
printf("please choose: ");
scanf("%d",&o);
switch(o) /*redirection*/
{
case 1:input(); break;
case 2:search(); break;
case 3:exit(1); break;
default: {printf("\n Not a option,Please choose again.");getch();} break;
}
}
return 0;
}
//---------------------------------------------------------------------------------
char loading()
{
int i,r;
printf("\n\n ");
for(i=1;i<29;i++)
{
system("cls"); //may i choose "clrscr"
printf("\n\n searching");
sleep(5);
for(r=30-i;r<30;r++)
printf(".");
//printf("@^_^@");
}
return 0;
}
//----------------------------------------------------------------------------------
char line(int n) /*define '*' */
{
int i;
for(i=1;i<=n;i++)
printf("*");
printf("\n");
return 0;
}
//-----------------------------------------------------------------------------------
int input()
{
int i,x;
system("cls");
printf(" Input Data(Total: %d)\n",N);
for(i=0;i<N;i++)
{
line(C); /*output '*'*/
printf("No.%d \n name: ",i+1);
scanf("%s",name[i]);
for(x=0;x<3;x++)
{ printf("\n score of %d: ",x);
scanf("%f",mark[i]);
}
printf("\n");
}
line(C);
getch();
return 0;
}
//----------------------------------------------------------------------------------
int search()
{
char sname[10];
int i,g;
system("cls");
printf(" Search System\n");
line(C); /*output '*'*/
printf("Please input Name: ");
scanf("%s",sname);
for(g=0;g<N;g++)
if(strcmp(sname,name[g])==0)
break;
if(g<N)
{
loading();
system("cls");
printf("\n Result of Search\n");
line(C); /*output '*'*/
{printf("Name: %s\n",name[g]);
printf("Score: %s\n",mark[g]);}
}
else
{
printf("There is NO result of Name: %s",sname);
}
getch();
return 0;
}