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> #define N 1025 int main() { int i, j, m, t, n, k, a[N]; scanf("%d", &m);; while( m-- ) { scanf("%d %d", &n, &k); for( i = 0; i < n; i++ ) scanf("%d", &a[i]); for( i = n-2 ; k; ) { for( j = n-1; j > i; j--) if( a[i] < a[j] ) { t = a[i]; a[i] = a[j]; a[j] = t; j = n-1; i++; for( ; i<j; j--, i++) { t = a[i]; a[i] = a[j]; a[j] = t; } i = n-2; j = n-1; k--; break; } if(i == 0&&j == 0) { j = n-1; for( ; i<j; i++, j--) { t = a[i]; a[i] = a[j]; a[j] = t; } i = n-2; j = n-1; k--; } else if(i == j) i--; } for(i = 0; i < n; i++) printf("%d ", a[i]); printf("\n"); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator