parent
660595f8f4
commit
4201cce589
@ -1,166 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
void input();
|
|
||||||
void delete1();
|
|
||||||
void select();
|
|
||||||
void order();
|
|
||||||
void output();
|
|
||||||
void quit();
|
|
||||||
void menu();
|
|
||||||
int sum=0;
|
|
||||||
|
|
||||||
struct stu
|
|
||||||
{
|
|
||||||
int Id;
|
|
||||||
int clas;
|
|
||||||
char name[10];
|
|
||||||
float score1;
|
|
||||||
float score2;
|
|
||||||
float score3;
|
|
||||||
float score;
|
|
||||||
}stu[1000];
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
while(1)
|
|
||||||
{
|
|
||||||
menu();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void menu()
|
|
||||||
{
|
|
||||||
printf(" 1.Input\n");
|
|
||||||
printf(" 2.delete\n");
|
|
||||||
printf(" 3.select\n");
|
|
||||||
printf(" 4.order\n");
|
|
||||||
printf(" 5.output\n");
|
|
||||||
printf(" 6.quit\n");
|
|
||||||
printf(" please input your option\n");
|
|
||||||
int t;
|
|
||||||
scanf("%d",&t);
|
|
||||||
switch(t)
|
|
||||||
{
|
|
||||||
case 1:input();break;
|
|
||||||
case 2:delete1();break;
|
|
||||||
case 3:select();break;
|
|
||||||
case 4:order();break;
|
|
||||||
case 5:output();break;
|
|
||||||
case 6:quit();break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void input()
|
|
||||||
{
|
|
||||||
sum=sum+1;
|
|
||||||
printf("Id ");
|
|
||||||
scanf("%d",&stu[sum].Id);
|
|
||||||
printf("class ");
|
|
||||||
scanf("%d",&stu[sum].clas);
|
|
||||||
printf("name ");
|
|
||||||
scanf("%s",&stu[sum].name);
|
|
||||||
printf("score1 ");
|
|
||||||
scanf("%f",&stu[sum].score1);
|
|
||||||
printf("score2 ");
|
|
||||||
scanf("%f",&stu[sum].score2);
|
|
||||||
printf("score3 ");
|
|
||||||
scanf("%f",&stu[sum].score3);
|
|
||||||
stu[sum].score=stu[sum].score3+stu[sum].score2+stu[sum].score1;
|
|
||||||
printf("continue?\n");
|
|
||||||
char a[10];
|
|
||||||
scanf("%s",&a);
|
|
||||||
if(a[0]=='y'&&a[1]=='e'&&a[2]=='s')
|
|
||||||
{
|
|
||||||
input();
|
|
||||||
}
|
|
||||||
else if(a[0]=='n'&&a[1]=='o')
|
|
||||||
{
|
|
||||||
menu();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void delete1()
|
|
||||||
{
|
|
||||||
char b[10];
|
|
||||||
scanf("%s",&b);
|
|
||||||
int c=0,len=strlen(b);
|
|
||||||
for(int k=0;k<len;k++)
|
|
||||||
{
|
|
||||||
c=c*10+b[k]-'0';
|
|
||||||
}
|
|
||||||
if(sum>1)
|
|
||||||
{
|
|
||||||
for(int i=1;i<=sum;i++)
|
|
||||||
{
|
|
||||||
if(stu[i].Id==c||stu[i].name==b)
|
|
||||||
{
|
|
||||||
for(int j=i;j<=sum;j++)
|
|
||||||
{
|
|
||||||
stu[j]=stu[j+1];
|
|
||||||
sum=sum-1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("can t");
|
|
||||||
}
|
|
||||||
output();
|
|
||||||
}
|
|
||||||
void select()
|
|
||||||
{
|
|
||||||
int b;
|
|
||||||
scanf("%d",&b);
|
|
||||||
for(int i=1;i<=sum;i++)
|
|
||||||
{
|
|
||||||
if(stu[i].Id==b||stu[i].clas==b)
|
|
||||||
{
|
|
||||||
printf("%d %d %s %f %f %f %f\n",stu[i].Id,stu[i].clas,stu[i].name,stu[i].score1,stu[i].score2,stu[i].score3,stu[i].score) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
char a[10];
|
|
||||||
scanf("%s",&a);
|
|
||||||
if(a[0]=='y'&&a[1]=='e'&&a[2]=='s')
|
|
||||||
{
|
|
||||||
select();
|
|
||||||
}
|
|
||||||
else if(a[0]=='n'&&a[1]=='o')
|
|
||||||
{
|
|
||||||
menu();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void order()
|
|
||||||
{
|
|
||||||
for(int i=1;i<=sum;i++)
|
|
||||||
{
|
|
||||||
for(int j=i;j<=sum;j++)
|
|
||||||
{
|
|
||||||
if(stu[i].clas>stu[j].clas)
|
|
||||||
{
|
|
||||||
stu[sum+1]=stu[i];
|
|
||||||
stu[i]=stu[j];
|
|
||||||
stu[j]=stu[sum+1];
|
|
||||||
}
|
|
||||||
else if(stu[i].clas==stu[j].clas)
|
|
||||||
{
|
|
||||||
if(stu[i].Id>stu[j].Id)
|
|
||||||
{
|
|
||||||
stu[sum+1]=stu[i];
|
|
||||||
stu[i]=stu[j];
|
|
||||||
stu[j]=stu[sum+1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void output()
|
|
||||||
{
|
|
||||||
for(int i=1;i<=sum;i++)
|
|
||||||
{
|
|
||||||
printf("%d %d %s %f %f %f %f\n",stu[i].Id,stu[i].clas,stu[i].name,stu[i].score1,stu[i].score2,stu[i].score3,stu[i].score);
|
|
||||||
}
|
|
||||||
menu();
|
|
||||||
}
|
|
||||||
void quit()
|
|
||||||
{
|
|
||||||
exit(0);
|
|
||||||
}
|
|
Loading…
Reference in new issue