4 1001 Li 76 1002 Zhang 92 1003 Liu 85 1004 Wang 70
Sample Output
1004 Wang 70 1001 Li 76 1003 Liu 85 1002 Zhang 92
Source
两种方法 1. 冒泡排序版
#include } 2. for(j=i;j<=n;j++) if(str[i].s>str[j].s){ str2=str[i]; str[i]=str[j]; str[j]=str2; } for(i=1;i<=n;i++) printf(\} return 0; Sort函数 #include boolcmp(grade a,grade b){ returna.s int main(void) { int n; gradestr[25],str2; while(scanf(\ { inti,j; for(i=1;i<=n;i++) scanf(\ sort(str+1,str+n+1,cmp); for(i=1;i<=n;i++) printf(\ } return 0; } 4016 Description 一个猴子在一座不超过30级的小山上爬山跳跃,猴子上山一步可跳1级或跳3级,试求上山有多少种不同的爬法 Input 多组测试数据,每组输入1个整数n,表示山的台阶数 Output 对于输入的整数n求出多少种爬法 Sample Input 30 Sample Output 58425 Source 分析:类似与铺瓷砖用f[i]代表到i米高的地方的走法总数,那么考虑到之前的位置只能在i-1和i-3,根据加法原理,f[i]=f[i-1]+f[i-2];初始状态f[1]=1;f[2]=1;f[3]=2; 代码: #include 4022 Description 把1到n2的正整数从左上角开始由外层至中心按照顺时针方向螺旋排列 Input 输入整数n (1 <= n <= 10) Output 按示例输出矩阵 Sample Input 3 4 Sample Output 1 2 3 8 9 4 7 6 5 1 2 3 4 12 13 14 5 11 16 15 6 10 9 8 7 Source 如果我不写注释你能看懂吗? 代码: #include
相关推荐: