📄 gexfglxt1.cpp
字号:
printf(" input the number you want to delete:");
scanf("%d",&number);
getchar();
}
#ifdef DEBUG
printf(" has been quitted!\n");
#endif
printf(" the number of the person is:%d个!\n",n);
return(head);
}
void print2311(score *head)
{
score *p;
if(head==NULL)
{printf(" \n no data!\n");}
else
{printf(" %d\n",n);
printf(" -----------------------------------------\n");
printf(" |number\t|name\t|life fee\t|studing fee\t|other fee\t|\n");
printf(" -----------------------------------------\n");
p=head;
do
{printf(" |%d\t|%s\t|%.1f\t|%.1f\t|%.1f\t|\n",p->number,p->name,p->living,p->study,p->other);
printf(" -----------------------------------------\n");
p=p->next;}while (p!=NULL);
}
}
score *statistics2311(score *head)
{
float sum1=0,sum2=0,sum3=0,ave1=0,ave2=0,ave3=0,max=0,min;
score *p;
int x,y=0,i=0;
p=head;
printf(" t1personal fee\t2average fee\t3highest fee\t4lowest fee\n");
scanf("%d",&x);
getchar();
switch(x)
{
case 1: if(head==NULL)
{printf(" \n no data!\n");return(head);}
else
{
printf(" ---------------------------------------------------------\n");
printf(" |number\t|name\t|life fee\t|studing fee\t|other fee\t|total fee\t|average fee\t|\n");
printf(" ---------------------------------------------------------\n");
while(p!=NULL)
{
sum1=p->living+p->study+p->other;
ave1=sum1/3;
printf(" |%d\t|%s\t|%.1f\t|%.1f\t|%.1f\t|%.1f\t|%.1f\t|\n",p->number,p->name,p->living,p->study,p->other,sum1,ave1);
printf(" ---------------------------------------------------------\n");
p=p->next;}
}
return(head); break;
case 2: if(head==NULL)
{printf(" \n no data!\n");return(head);}
while(p!=NULL)
{
sum1=sum1+p->living;
sum2=sum2+p->study;
sum3=sum3+p->other;
y=y+1;
ave1=sum1/y;
ave2=sum2/y;
ave3=sum3/y;
p=p->next;
}
printf(" the average of the living fee%.1f\n",ave1);
printf(" the average of the studing fee%.1f\n",ave2);
printf(" the average of the other fee%.1f\n",ave3);
return(head); break;
case 3:
if(head==NULL)
{printf(" \n no data!\n");return(head);}
max=p->living+p->study+p->other;
while(i<n)
{
i=i+1;
sum1=p->living+p->study+p->other;
if(max<sum1)
max=sum1;
p=p->next;
}
printf(" highest total fee:%.1f",max);
printf(" \n");
return(head); break;
case 4: if(head==NULL)
{printf(" \n no data!\n");return(head);}
while(p!=NULL)
{
min=p->living+p->study+p->other;
while(p!=NULL)
{sum2=p->living+p->study+p->other;
if(min>sum2)
min=sum2;
p=p->next;
}
}
printf(" the lowest total fee:%.1f",min);
printf(" \n");
return(head); break;
default :printf(" wrong input please input again!\n");
}
return(head);
}
save2311(score *p1)
{
FILE *fp;
char filepn[20];
printf(" please input the name of the file:");
scanf("%s",filepn);
if((fp=fopen(filepn,"w+"))==NULL)
{
printf(" can not open!\n");
return 0;
}
fprintf(fp,"\t\t\t\tpersonal consuming system \n");
fprintf(fp,"-----------------------------------------\n");
fprintf(fp,"|number\t|name\t|life fee\t|studing fee\t|other fee\t|\n");
fprintf(fp,"-----------------------------------------\n");
while(p1!=NULL)
{
fprintf(fp,"%d\t%s\t%.1f\t%.1f\t%.1f\t\n",p1->number,p1->name,p1->living,p1->study,p1->other);
p1=p1->next;
}
fclose(fp);
printf(" file has been saved!\n");
return 0;
}
score *taxis2311(score *head)
{ score *p,*max;
int i,j,x;
float fen;
char t[10];
if(head==NULL)
{printf(" \n no data please creat the link!\n");return(head);}
max=p=head;
printf(" ******************************************************** \n");
printf(" * 1.line by the number 2.line by the number *\n");
printf(" * 3.line by the life 4.line by the studing *\n");
printf(" * 5.other fee *\n");
printf(" ******************************************************** \n");
printf(" please deal with:");
scanf("%d",&x);
getchar();
switch(x)
{case 1 :
for(i=1;i<n;i++)
{
for(j=i+1;j<=n;j++)
{
max=p;
p=p->next;
if(max->number>p->number)
{
k=max->number;
max->number=p->number;
p->number=k;
strcpy(t,max->name);
strcpy(max->name,p->name);
strcpy(p->name,t);
fen=max->living;
max->living=p->living;
p->living=fen;
fen=max->study;
max->study=p->study;
p->study=fen;
fen=max->other;
max->other=p->other;
p->other=fen;
}
}
max=head;p=head;
}
print2311(head);break;
case 2 : for(i=1;i<n;i++)
{
for(j=i+1;j<=n;j++)
{
max=p;
p=p->next;
if(strcmp(max->name,p->name)>0)
{
strcpy(t,max->name);
strcpy(max->name,p->name);
strcpy(p->name,t);
k=max->number;
max->number=p->number;
p->number=k;
fen=max->living;
max->living=p->living;
p->living=fen;
fen=max->study;
max->study=p->study;
p->study=fen;
fen=max->other;
max->other=p->other;
p->other=fen;
}
}
p=head;
max=head;
}
print2311(head);
break;
case 3 : for(i=1;i<n;i++)
{for(j=i+1;j<=n;j++)
{max=p;
p=p->next;
if(max->living>p->living)
{
fen=max->living;
max->living=p->living;
p->living=fen;
k=max->number;
max->number=p->number;
p->number=k;
strcpy(t,max->name);
strcpy(max->name,p->name);
strcpy(p->name,t);
fen=max->study;
max->study=p->study;
p->study=fen;
fen=max->other;
max->other=p->other;
p->other=fen;
}
}
p=head;
max=head;
}
print2311(head);
break;
case 4 : for(i=1;i<n;i++)
{for(j=i+1;j<=n;j++)
{max=p;
p=p->next;
if(max->study>p->study)
{
fen=max->study;
max->study=p->study;
p->study=fen;
k=max->number;
max->number=p->number;
p->number=k;
strcpy(t,max->name);
strcpy(max->name,p->name);
strcpy(p->name,t);
fen=max->living;
max->living=p->living;
p->living=fen;
fen=max->other;
max->other=p->other;
p->other=fen;
}
}
p=head;
max=head;
}
print2311(head);
break;
case 5 : for(i=1;i<n;i++)
{for(j=i+1;j<=n;j++)
{max=p;
p=p->next;
if(max->other>p->other)
{
fen=max->other;
max->other=p->other;
p->other=fen;
k=max->number;
max->number=p->number;
p->number=k;
strcpy(t,max->name);
strcpy(max->name,p->name);
strcpy(p->name,t);
fen=max->living;
max->living=p->living;
p->living=fen;
fen=max->study;
max->study=p->study;
p->study=fen;
}
}
p=head;
max=head;
}
print2311(head);
break;
default :printf(" wrong input please input again! \n");
}
return (0);}
int menu2311(k)
{
printf(" \n");
printf("\t\t\t\tpersonal conumsing system\n");
printf(" *********************************************************** \n");
printf(" * 1.input the data of person 2.check the data of the person *\n");
printf(" * 3.get the data of file 4.account the data of the person *\n");
printf(" * 5.add the data of the person 6.show the fee of the person *\n");
printf(" * 7.delete the data of the person 8.rank the fee *\n");
printf(" * 9.save the personal data 0.quit *\n");
printf(" *********************************************************** \n");
printf(" welcome to the personal consuming system!\n choose your choice(choose(0)\delete):");
scanf("%d",&k);
getchar();
return (k);}
main()
{score *head=0,*stu=0;
while(1)
{k=menu2311(k);
switch(k)
{case 1: head=creat2311();break;
case 2: head=search2311(head);break;
case 3: head=load2311(head);break;
case 4: statistics2311(head); break;
case 5: head=add2311(head,stu);break;
case 6: print2311(head); break;
case 7: head=del2311(head); break;
case 8: taxis2311(head);break;
case 9: save2311(head);break;
case 0: exit(0);
default: printf(" wrong input please input again!\n"); }
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -