0
我在這裏找不到任何錯誤。該程序的目的是將所有可能的數組元素和它們的總和組合起來。我試圖編寫一個程序,它會返回一個元素數組,其中每個下一個元素不等於前一個元素或之前任何元素組合的總和。我開始喜歡這個,但是遇到一個錯誤:它說,程序已停止工作......簡單的C程序錯誤
#include <stdio.h>
int m[20];
void initm(int x[]) {
for(int i=0; i<20; i++) {
m[i]=i;
}
}
void sorter(int x[]) {
for(int i=0; i<20; i++) {
for(int j=0; j<20; j++) {
/* nested for loop to get all possible combinations */
printf("%d===%d===%d", x[i], x[j], x[i]+x[j]);
}
}
}
int main() {
initm(m[20]);
sorter(m[20]);
return 0;
}
''我在這裏找不到任何錯誤''你看看你的編譯器的輸出消息嗎? –