禽兽馆

你够出色“禽兽”的标准吗?请成为我们的一员吧!

128 成员1,018 主题3,471 回复59 张照片

想不想要计算机的答案?

教
教主夫人
2002-06-28 17:35
#include <stdio.h>
#include <string.h>
struct student
{
int num;
char name[8];
int score;
}st[50],t;
input()
{
FILE *fp;
int i;
for (i=0;i<5;i++)
scanf("%d %s %d\n",&st[i].num,st[i].name,&st[i].score);
fp=fopen("qdata.txt","w");
if (fp==NULL)
exit(1);
for (i=0;i<5;i++)
{
fprintf(fp,"%d ",st[i].num);
fprintf(fp,"%s ",st[i].name);
fprintf(fp,"%d \n",st[i].score);
}
fclose(fp);
}
display()
{
FILE *fp;
int i;
char random[20];
fp=fopen("qdata.txt","r");
if (fp==NULL)
exit(1);
for (i=0;i<5;i++)
fscanf(fp,"%d %s %d\n",&st[i].num,st[i].name,&st[i].score);
fclose(fp);
for (i=0;i<5;i++)
printf("%d %s %d\n",st[i].num,st[i].name,st[i].score);
scanf("%s",random);
}
insert()
{
FILE *fp;
int i,j;
char random[20];
fp=fopen("qdata.txt","r");
if (fp==NULL)
exit(1);
for (i=0;i<5;i++)
fscanf(fp,"%d %s %d\n",&st[i].num,st[i].name,&st[i].score);
for (i=0;i<4;i++)
for (j=i+1;j<5;j++)
if (strcmp(st[i].name,st[j].name)>0)
{
t=st[i];
st[i]=st[j];
st[j]=t;
}
scanf("%d %s %d\n",&st[5].num,st[5].name,&st[5].score);
for (i=0;i<5;i++)
if (strcmp(st[5].name,st[i].name)<0)
{
t=st[i];
st[i]=st[5];
st[5]=t;
}
for (i=0;i<6;i++)
printf("%d %s %d\n",st[i].num,st[i].name,st[i].score);
scanf("%s",random);
}
seek()
{
FILE *fp;
char random[10];
int num,i;
fp=fopen("qdata.txt","r");
if (fp==NULL)
exit(1);
for (i=0;i<5;i++)
fscanf(fp,"%d %s %d\n",&st[i].num,st[i].name,&st[i].score);
fclose(fp);
scanf("%d",&num);
for (i=0;i<5;i++)
if (num==st[i].num)
printf("%d %s %d\n",st[i].num,st[i].name,st[i].score);
scanf("%s",random);
}
del()
{
FILE *fp;
char random[10];
int num,i,j;
fp=fopen("qdata.txt","r");
if (fp==NULL)
exit(1);
for (i=0;i<5;i++)
fscanf(fp,"%d %s %d\n",&st[i].num,st[i].name,&st[i].score);
fclose(fp);
scanf("%d",&num);
for (i=0;i<5;i++)
if (num==st[i].num)
for (j=i+1;j<5;j++)
st[j-1]=st[j];
for (i=0;i<4;i++)
printf("%d %s %d\n",st[i].num,st[i].name,st[i].score);
scanf("%s",random);
}
descend()
{
FILE *fp;
int i,j;
char random[10];
fp=fopen("qdata.txt","r");
if (fp==NULL)
exit(1);
for (i=0;i<5;i++)
fscanf(fp,"%d %s %d\n",&st[i].num,st[i].name,&st[i].score);
for (i=0;i<5;i++)
fscanf(fp,"%d %s %d\n",&st[i].num,st[i].name,&st[i].score);
for (i=0;i<4;i++)
for (j=i+1;j<5;j++)
if (st[i].score<st[j].score)
{
t=st[i];
st[i]=st[j];
st[j]=t;
}
for (i=0;i<5;i++)
printf("%d %s %d\n",st[i].num,st[i].name,st[i].score);
scanf("%s",random);
fp=fopen("qdata.txt","w");
if (fp==NULL)
exit(1);
for (i=0;i<5;i++)
fprintf(fp,"%d %s %d\n",st[i].num,st[i].name,st[i].score);
fclose(fp);
}
number()
{
}
average()
{

FILE *fp;
int i,sum,avg;
char random[10];
fp=fopen("qdata.txt","r");
if (fp==NULL)
exit(1);
for (i=0;i<5;i++)
fscanf(fp,"%d %s %d\n",&st[i].num,st[i].name,&st[i].score);
sum=0;
for (i=0;i<5;i++)
sum=sum+st[i].score;
avg=sum/5;
printf("%d\n",avg);
scanf("%s",random);
}
best()
{
FILE *fp;
int i,j,max;
char random[10];
fp=fopen("qdata.txt","r");
if (fp==NULL)
exit(1);
for (i=0;i<5;i++)
fscanf(fp,"%d %s %d\n",&st[i].num,st[i].name,&st[i].score);
max=st[0].score;
for (i=0;i<5;i++)
if (max<=st[i].score)
{
max=st[i].score;
j=i;
}
printf("%d %s %d\n",st[j].num,st[j].name,st[j].score);
scanf("%s",random);
}
main()
{
while (1)
{
char i;
clrscr();
printf("\t\t\t\tMenu\n\n");
printf("\t\t1 Input record\n");
printf("\t\t2 Display record\n");
printf("\t\t3 Insert record\n");
printf("\t\t4 Seek record\n");
printf("\t\t5 Delete record\n");
printf("\t\t6 Sort descending records according to sore\n");
printf("\t\t7 Count the number of student\n");
printf("\t\t8 Count the average score of all students\n");
printf("\t\t9 Display the best student among all the students\n\t\t");
printf("0 Exit\n\t\t");
printf("=================================================\n\t\t");
printf("Please enter your choice:");
scanf("%c",&i);
switch (i)
{
case '1':input();break;
case '2':display();break;
case '3':insert();break;
case '4':seek();break;
case '5':del();break;
case '6':descend();break;
case '7':number();break;
case '8':average();break;
case '9':best();break;
case '0':exit(1);break;
}
}
}


落
落英缤纷
2002-06-29 01:48
KAO
谁做的?教主吧!
Post hoc, non propter hoc

香
香阁里拉
2002-06-29 04:13
明知故问嘛
她不就是想显示一下自己和教主的关系发展得如何呀!
教
教主夫人
2002-06-29 05:08
哎~知己莫若“禽兽”
我们发展得不错。只可惜明年的计算机中级没有他,希望他这次的中级不要考出来,等我以后一起和他努奋斗!!
香
香阁里拉
2002-06-29 05:45
绝倒
要知道失败的男人后面就有这样的女人!
网
网事无痕
2002-06-29 18:42
有了这样的女人,男人才会失败!
网
网事无痕
2002-06-29 18:45
一年后你们所说的“教主”就会和我一起远度重洋!
那时“教主夫人”也只有为伊消的人憔悴了!
教
教主夫人
2002-07-02 05:26
谁说的?!
谁说的?!我也去!!
you jump, I jump!
霖
霖晓
2002-07-02 20:57
浪漫樱花??好!!
霖
霖晓
2002-07-02 20:57
哇,你们都要走啊!!走啊,走啊,你们都走了,我来称霸!哈哈
月
月色如夏
2002-07-02 21:24
乐乐,人家改变心意了,不走了,人家来陪你,OK?
“禽”之以情,“兽”之以理。
喜怒哀乐,森罗万象,尽在“禽兽馆”!
稍后请继续收看……
禽兽馆
教
教主夫人
2002-07-03 04:14
哈哈
哈哈,很期待乐乐称霸的样子哎!
霖
霖晓
2002-07-07 02:43
唉,可惜你要走啊,看不到小女的风光日子啊!可惜啊,可惜!
霖
霖晓
2002-07-07 02:43
谁跟你OK啊!不OK!你们统统给我走!
香
香阁里拉
2002-07-07 03:26
如果大家都走了,那还有什么意思啊!
1 / 1

登录后回复。