Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
为什么我的程序总是runtime error啊?帮帮忙啊!#include<stdio.h> int main() { int n, m, i, j, k, p, r, q, temp, t, temp1; char a[105][55]; int b[55], c[55]; scanf("%d%d",&n,&m); getchar(); for(i = 0; i < 55; i++) { b[i] = 0; } i = 0; p = 0; for(j = 0; j < 55; j++) { c[j] = 0; } while(m--) { gets(a[i]); for(j = 0; j < n - 1; j++) { for(k = j + 1; k < n; k++) { if(a[i][j] > a[i][k]) b[i]++; } } c[p++] = i; i++; } for(r = 0; r < p; r++) { t = r; for(q = r + 1; q < p; q++) { if(b[q] < b[t]) t = q; } temp = c[r]; c[r] = c[t]; c[t] = temp; temp1 = b[r]; b[r] = b[t]; b[t] = temp1; } for(r = 0; r < p; r++) { puts(a[c[r]]); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator