|
|
|
@ -121,4 +121,364 @@ scanf("%f",&student3.yy);
|
|
|
|
|
printf("%d,%.1f,%.1f\n", student3.number, student3.add, student3.aver);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
步骤四
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
int num[4],cla[4];
|
|
|
|
|
float f[4],s[4],t[4],add[4];
|
|
|
|
|
int begin,sta;
|
|
|
|
|
int n=4;
|
|
|
|
|
int insert;
|
|
|
|
|
void sort(float add[])
|
|
|
|
|
{
|
|
|
|
|
int i,j,te;
|
|
|
|
|
float zh;
|
|
|
|
|
for(i=n-1;i>sta;i--)
|
|
|
|
|
{
|
|
|
|
|
if(add[i]>add[i-1])
|
|
|
|
|
{
|
|
|
|
|
zh=add[i];add[i]=add[i-1];add[i-1]=zh;
|
|
|
|
|
te=num[i];num[i]=num[i-1];num[i-1]=te;
|
|
|
|
|
zh=f[i];f[i]=f[i-1];f[i-1]=zh;
|
|
|
|
|
zh=s[i];s[i]=s[i-1];s[i-1]=zh;
|
|
|
|
|
zh=t[i];t[i]=t[i-1];t[i-1]=zh;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(n!=sta+1)
|
|
|
|
|
{
|
|
|
|
|
sta++;
|
|
|
|
|
sort(add);}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void div(int clas[])
|
|
|
|
|
{
|
|
|
|
|
int i,j,te;
|
|
|
|
|
float zh;
|
|
|
|
|
for(i=0;i<n-1;i++)
|
|
|
|
|
{
|
|
|
|
|
if(clas[i]>clas[i+1])
|
|
|
|
|
{
|
|
|
|
|
te=clas[i];clas[i]=clas[i+1];clas[i+1]=te;
|
|
|
|
|
zh=add[i];add[i]=add[i+1];add[i+1]=zh;
|
|
|
|
|
te=num[i];num[i]=num[i+1];num[i+1]=te;
|
|
|
|
|
zh=f[i];f[i]=f[i+1];f[i+1]=zh;
|
|
|
|
|
zh=s[i];s[i]=s[i+1];s[i+1]=zh;
|
|
|
|
|
zh=t[i];t[i]=t[i+1];t[i+1]=zh;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(n!=sta+1){
|
|
|
|
|
n--;
|
|
|
|
|
div(clas);}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
void sort(float add[]);
|
|
|
|
|
void div(int clas[]);
|
|
|
|
|
num[0]=10001;num[1]=10002;num[2]=10003;
|
|
|
|
|
cla[0]=11;cla[1]=12;cla[2]=11;
|
|
|
|
|
f[0]=99.5;f[1]=77.9;f[2]=92.5;
|
|
|
|
|
s[0]=88.5;s[1]=56.5;s[2]=99.0;
|
|
|
|
|
t[0]=89.5;t[1]=87.5;t[2]=60.5;
|
|
|
|
|
for(int i=0;i<3;i++)
|
|
|
|
|
{
|
|
|
|
|
add[i]=f[i]+s[i]+t[i];
|
|
|
|
|
}
|
|
|
|
|
scanf("%d",&num[3]);
|
|
|
|
|
insert=num[3];
|
|
|
|
|
int in=num[3];
|
|
|
|
|
for(int i=0;i<3;i++){
|
|
|
|
|
if(in==num[i]){
|
|
|
|
|
printf("%d %d %f %f %f %f",num[i],cla[i],f[i],s[i],t[i],add[i]);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
scanf("%d",&cla[3]);
|
|
|
|
|
scanf("%f",&f[3]);
|
|
|
|
|
scanf("%f",&s[3]);
|
|
|
|
|
scanf("%f",&t[3]);
|
|
|
|
|
add[3]=f[3]+s[3]+t[3];
|
|
|
|
|
sta=0;begin=0;
|
|
|
|
|
div(cla);
|
|
|
|
|
n=4;
|
|
|
|
|
int m;
|
|
|
|
|
for(m=0;m<n;m++){
|
|
|
|
|
if(cla[m]!=cla[m+1])
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
sta=m;begin=sta;
|
|
|
|
|
sort(add);
|
|
|
|
|
n=m+1;
|
|
|
|
|
sta=0;begin=sta;
|
|
|
|
|
sort(add);
|
|
|
|
|
n=4;
|
|
|
|
|
for(int j=0;j<n;j++){
|
|
|
|
|
printf("%d %d %f %f %f %f",num[j],cla[j],f[j],s[j],t[j],add[j]);
|
|
|
|
|
if(num[j]==insert) printf(" insert\n");
|
|
|
|
|
else printf("\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
步骤五
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
int num[4],cla[4];
|
|
|
|
|
float f[4],s[4],t[4],add[4];
|
|
|
|
|
int begin,sta;
|
|
|
|
|
int n=3;
|
|
|
|
|
int insert;
|
|
|
|
|
char name[4][10]={{"Zhang"},{"Yang"},{"Liang"}};
|
|
|
|
|
void sort(float add[])
|
|
|
|
|
{
|
|
|
|
|
int i,j,te;
|
|
|
|
|
float zh;
|
|
|
|
|
char oo[10];
|
|
|
|
|
for(i=n-1;i>sta;i--)
|
|
|
|
|
{
|
|
|
|
|
if(add[i]>add[i-1])
|
|
|
|
|
{
|
|
|
|
|
zh=add[i];add[i]=add[i-1];add[i-1]=zh;
|
|
|
|
|
te=num[i];num[i]=num[i-1];num[i-1]=te;
|
|
|
|
|
zh=f[i];f[i]=f[i-1];f[i-1]=zh;
|
|
|
|
|
zh=s[i];s[i]=s[i-1];s[i-1]=zh;
|
|
|
|
|
zh=t[i];t[i]=t[i-1];t[i-1]=zh;
|
|
|
|
|
strcpy(oo,name[i]);strcpy(name[i],name[i-1]);
|
|
|
|
|
strcpy(name[i-1],oo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(n!=sta+1)
|
|
|
|
|
{
|
|
|
|
|
sta++;
|
|
|
|
|
sort(add);}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void div(int clas[])
|
|
|
|
|
{
|
|
|
|
|
int i,j,te;
|
|
|
|
|
float zh;
|
|
|
|
|
char oo[10];
|
|
|
|
|
for(i=0;i<n-1;i++)
|
|
|
|
|
{
|
|
|
|
|
if(clas[i]>clas[i+1])
|
|
|
|
|
{
|
|
|
|
|
te=clas[i];clas[i]=clas[i+1];clas[i+1]=te;
|
|
|
|
|
zh=add[i];add[i]=add[i+1];add[i+1]=zh;
|
|
|
|
|
te=num[i];num[i]=num[i+1];num[i+1]=te;
|
|
|
|
|
zh=f[i];f[i]=f[i+1];f[i+1]=zh;
|
|
|
|
|
zh=s[i];s[i]=s[i+1];s[i+1]=zh;
|
|
|
|
|
zh=t[i];t[i]=t[i+1];t[i+1]=zh;
|
|
|
|
|
strcpy(oo,name[i]);strcpy(name[i],name[i+1]);
|
|
|
|
|
strcpy(name[i+1],oo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(n!=sta+1){
|
|
|
|
|
n--;
|
|
|
|
|
div(clas);}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
void sort(float add[]);
|
|
|
|
|
void div(int clas[]);
|
|
|
|
|
num[0]=10001;num[1]=10002;num[2]=10003;
|
|
|
|
|
cla[0]=11;cla[1]=12;cla[2]=11;
|
|
|
|
|
f[0]=99.5;f[1]=77.9;f[2]=92.5;
|
|
|
|
|
s[0]=88.5;s[1]=56.5;s[2]=99.0;
|
|
|
|
|
t[0]=89.5;t[1]=87.5;t[2]=60.5;
|
|
|
|
|
sta=0;begin=0;
|
|
|
|
|
div(cla);
|
|
|
|
|
n=3;
|
|
|
|
|
int m;
|
|
|
|
|
for(m=0;m<n;m++){
|
|
|
|
|
if(cla[m]!=cla[m+1])
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
sta=m;begin=sta;
|
|
|
|
|
sort(add);
|
|
|
|
|
n=m+1;
|
|
|
|
|
sta=0;begin=sta;
|
|
|
|
|
sort(add);
|
|
|
|
|
n=3;
|
|
|
|
|
scanf("delete");
|
|
|
|
|
scanf("%s",name[3]);
|
|
|
|
|
int exist=0,target;
|
|
|
|
|
if(name[3][0]>='0'&&name[3][0]<='9')
|
|
|
|
|
{
|
|
|
|
|
int number=atoi(name[3]);
|
|
|
|
|
for(int i=0;i<3;i++){
|
|
|
|
|
if(number==num[i]){
|
|
|
|
|
printf("Are you sure?");
|
|
|
|
|
exist=1;
|
|
|
|
|
target=i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for(int i=0;i<3;i++){
|
|
|
|
|
if(strcmp(name[i],name[3]));
|
|
|
|
|
else{
|
|
|
|
|
printf("Are you sure?\n");
|
|
|
|
|
exist=1;
|
|
|
|
|
target=i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
char ch;
|
|
|
|
|
if(exist==1){
|
|
|
|
|
scanf(" %c",&ch);
|
|
|
|
|
if(ch=='y'){
|
|
|
|
|
for(int i=0;i<3;i++){
|
|
|
|
|
if(i!=target){
|
|
|
|
|
printf("%d %d %s %.2f %.2f %.2f\n",num[i],cla[i],name[i],f[i],s[i],t[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(ch=='n'){
|
|
|
|
|
for(int i=0;i<3;i++){
|
|
|
|
|
printf("%d %d %s %.2f %.2f %.2f\n",num[i],cla[i],name[i],f[i],s[i],t[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
for(int i=0;i<3;i++){
|
|
|
|
|
printf("%d %d %s %.2f %.2f %.2f\n",num[i],cla[i],name[i],f[i],s[i],t[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
步骤六
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
int num[4],cla[4];
|
|
|
|
|
float f[4],s[4],t[4],add[4];
|
|
|
|
|
int begin,sta;
|
|
|
|
|
int n=3;
|
|
|
|
|
int insert;
|
|
|
|
|
char name[4][10]={{"Zhang"},{"Yang"},{"Liang"}};
|
|
|
|
|
void sort(float add[])
|
|
|
|
|
{
|
|
|
|
|
int i,j,te;
|
|
|
|
|
float zh;
|
|
|
|
|
char oo[10];
|
|
|
|
|
for(i=n-1;i>sta;i--)
|
|
|
|
|
{
|
|
|
|
|
if(add[i]>add[i-1])
|
|
|
|
|
{
|
|
|
|
|
zh=add[i];add[i]=add[i-1];add[i-1]=zh;
|
|
|
|
|
te=num[i];num[i]=num[i-1];num[i-1]=te;
|
|
|
|
|
zh=f[i];f[i]=f[i-1];f[i-1]=zh;
|
|
|
|
|
zh=s[i];s[i]=s[i-1];s[i-1]=zh;
|
|
|
|
|
zh=t[i];t[i]=t[i-1];t[i-1]=zh;
|
|
|
|
|
strcpy(oo,name[i]);strcpy(name[i],name[i-1]);
|
|
|
|
|
strcpy(name[i-1],oo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(n!=sta+1)
|
|
|
|
|
{
|
|
|
|
|
sta++;
|
|
|
|
|
sort(add);}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void div(int clas[])
|
|
|
|
|
{
|
|
|
|
|
int i,j,te;
|
|
|
|
|
float zh;
|
|
|
|
|
char oo[10];
|
|
|
|
|
for(i=0;i<n-1;i++)
|
|
|
|
|
{
|
|
|
|
|
if(clas[i]>clas[i+1])
|
|
|
|
|
{
|
|
|
|
|
te=clas[i];clas[i]=clas[i+1];clas[i+1]=te;
|
|
|
|
|
zh=add[i];add[i]=add[i+1];add[i+1]=zh;
|
|
|
|
|
te=num[i];num[i]=num[i+1];num[i+1]=te;
|
|
|
|
|
zh=f[i];f[i]=f[i+1];f[i+1]=zh;
|
|
|
|
|
zh=s[i];s[i]=s[i+1];s[i+1]=zh;
|
|
|
|
|
zh=t[i];t[i]=t[i+1];t[i+1]=zh;
|
|
|
|
|
strcpy(oo,name[i]);strcpy(name[i],name[i+1]);
|
|
|
|
|
strcpy(name[i+1],oo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(n!=sta+1){
|
|
|
|
|
n--;
|
|
|
|
|
div(clas);}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
void sort(float add[]);
|
|
|
|
|
void div(int clas[]);
|
|
|
|
|
num[0]=10001;num[1]=10002;num[2]=10003;
|
|
|
|
|
cla[0]=11;cla[1]=12;cla[2]=11;
|
|
|
|
|
f[0]=99.5;f[1]=77.9;f[2]=92.5;
|
|
|
|
|
s[0]=88.5;s[1]=56.5;s[2]=99.0;
|
|
|
|
|
t[0]=89.5;t[1]=87.5;t[2]=60.5;
|
|
|
|
|
sta=0;begin=0;
|
|
|
|
|
div(cla);
|
|
|
|
|
n=3;
|
|
|
|
|
int m;
|
|
|
|
|
for(m=0;m<n;m++){
|
|
|
|
|
if(cla[m]!=cla[m+1])
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
sta=m;begin=sta;
|
|
|
|
|
sort(add);
|
|
|
|
|
n=m+1;
|
|
|
|
|
sta=0;begin=sta;
|
|
|
|
|
sort(add);
|
|
|
|
|
n=3;
|
|
|
|
|
int i;
|
|
|
|
|
int changer1,changer2,target,input;
|
|
|
|
|
float changer4,changer5,changer6;
|
|
|
|
|
scanf("%d",&changer1);
|
|
|
|
|
for(i=0;i<3;i++){
|
|
|
|
|
if(num[i]==changer1){input=1;break;}
|
|
|
|
|
else input=0;
|
|
|
|
|
}
|
|
|
|
|
char changer[10];
|
|
|
|
|
scanf("%d",&changer2);
|
|
|
|
|
scanf("%s",changer);
|
|
|
|
|
scanf("%f",&changer4);
|
|
|
|
|
scanf("%f",&changer5);
|
|
|
|
|
scanf("%f",&changer6);
|
|
|
|
|
if(input==0){
|
|
|
|
|
for(i=0;i<3;i++){
|
|
|
|
|
printf("%d %d %s %.2f %.2f %.2f\n",num[i],cla[i],name[i],f[i],s[i],t[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
i=target;
|
|
|
|
|
cla[i]=changer2;strcpy(name[i],changer);f[i]=changer4;
|
|
|
|
|
s[i]=changer5;t[i]=changer6;
|
|
|
|
|
sta=0;begin=0;
|
|
|
|
|
div(cla);
|
|
|
|
|
n=3;
|
|
|
|
|
int m;
|
|
|
|
|
for(m=0;m<n;m++){
|
|
|
|
|
if(cla[m]!=cla[m+1])
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
sta=m;begin=sta;
|
|
|
|
|
sort(add);
|
|
|
|
|
n=m+1;
|
|
|
|
|
sta=0;begin=sta;
|
|
|
|
|
sort(add);
|
|
|
|
|
for(i=0;i<3;i++){
|
|
|
|
|
printf("%d %d %s %.2f %.2f %.2f\n",num[i],cla[i],name[i],f[i],s[i],t[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|