标签:source memory pre ref lin 报名 header struct 多少
3 10 1 2 3 2 3 1 2 3 1 3
3 4
1 #include <stdio.h> 2 #include <stdlib.h> 3 struct 4 { 5 int name,score; 6 }a[1001]={{0,0}},t; 7 8 int main() 9 { 10 int m,n,x,i,j; 11 scanf("%d %d",&m,&n); 12 for(i=0;i<=n-1;i++) 13 { 14 scanf("%d",&x); 15 if(x<=m&&x>0) 16 { 17 a[x-1].score++; 18 a[x-1].name=x; 19 } 20 } 21 for(i=0;i<=m-2;i++) 22 { 23 for(j=0;j<=m-2-i;j++) 24 { 25 if(a[j].score<a[j+1].score) 26 { 27 t=a[j]; 28 a[j]=a[j+1]; 29 a[j+1]=t; 30 } 31 } 32 } 33 printf("%d\n%d\n",a[0].name,a[0].score); 34 return 0; 35 }
标签:source memory pre ref lin 报名 header struct 多少
原文地址:https://www.cnblogs.com/xiaolitongxueyaoshangjin/p/12034463.html