为什么是通过不了,在电脑上还是可以运行的,感觉没错,求大神指点!!!
查看原帖
为什么是通过不了,在电脑上还是可以运行的,感觉没错,求大神指点!!!
291718
苍苍蒹葭楼主2020/10/13 14:31
#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main() {
	int N,a[N], i = 1, k = 0, j, tmp;
	printf("请输入车厢的节数:");
	scanf("%d",&N);
	printf("\n");
	printf("输入车厢的编号:");
	while(i<=N){
		a[i] = N - i +1;
		printf("%d",a[i]);
		i++;
	}
	printf("\n");
	for(i=0;i<N-1;i++){
		for(j=0;j<N-(i+1);j++){
			tmp = a[i];
			a[i] = a[i+1];
			a[i+1] = tmp;
			k++;
		}
	}
	printf("转化的次数:%d",k);
	return 0;
}
2020/10/13 14:31
加载中...