一个在 pongo 不能成功提交的小题目,了解 pongo 的请进
在 pongo 找的题目,就是不能提交成功,我也感觉代码符合题目要求,现在贴出代码与题目,求不能成功提交的原因?
程序代码:
#include <iostream> using namespace std; int run(const int *a,int n) { if (n == 1) return 0; int array[100]; static int number = 0; for (int i = 0; i < n; i++) array[i] = a[i]; int max = array[n-1], pos = n-1; for (int i = n-2; i >= 0; i--){ if (max < array[i]){ max = array[i]; pos = i; } } if (max != array[n-1]){ int temp; temp = array[n-1]; array[n-1] = max; array[pos] = temp; number++; } run(array, n-1); return number; } int main() { int a[] = {1,2,3,4,5,6,7,8,9,10, 11,12,13,14,15,16,17,18,19,20, 21,22,23,24,25,26,27,28,29,30, 31,32,33,34,35,36,37,38,39,40, 41,42,43,44,45,46,47,48,49,50, 51,52,53,54,55,56,57,58,59,60, 61,62,63,64,65,66,67,68,69,70, 71,72,73,74,75,76,77,78,79,80, 81,82,83,84,85,86,87,88,89,90, 91,92,93,94,95,96,97,98,99,100}, n = 100; n = run(a, n); cout << n; return 0; }
此程序编译运行正常,大家看看符合题目要求不?哪里不符合?
[ 本帖最后由 yss28 于 2013-11-3 16:15 编辑 ]