#include <stdio.h>
swap(int a[],int b[],int c[])
{
int i,j;
for(i=0;i<5;i++){
for(j=0;j<5;j++){
if(a[i]==b[j])
c[i]=j;}}
}
struct stu
{
int id;
char num[10];
int c;
};
int main()
{
struct stu s[5]={{201,"Zhang",78},{202,"Li",85},{203,"Wang",60},{204,"Wang",75},{205,"Xue",80}};
int i,j,k,a[5]={78,85,60,75,80},b[5]={78,85,60,75,80},h[5],n;
scanf("%d",&n);
if(n==1){
for(i=0;i<4;i++){
for(j=i+1;j<5;j++){
if(a[i]<a[j]){
k=a[i];
a[i]=a[j];
a[j]=k;}}}
swap(a,b,h);
for(i=0;i<5;i++){
printf("%d\t%s\t%d\n",s[h[i]].id,s[h[i]].num,s[h[i]].c);}}
if(n==2){
for(i=0;i<4;i++){
for(j=i+1;j<5;j++){
if(a[i]>a[j]){
k=a[i];
a[i]=a[j];
a[j]=k;}}}
swap(a,b,h);
for(i=0;i<5;i++){
printf("%d\t%s\t%d\n",s[h[i]].id,s[h[i]].num,s[h[i]].c);}}
}
网友评论