我會如何處理已經計算的數字並將它們輸入到數組中? 舉例來說,如果我有以下功能:將數字輸出寫入數組
int sum_even (int p1, int p3, int p5, int p7, int p9, int p11){
even_total = array_1[1] + array_1[3] + array_1[5] + array_1[7] + array_1[9] + array_1[11];
printf("The sum of the even numbers: %d\n", even_total);
return;
}
int sum_odd (int p2, int p4, int p6, int p8, int p10, int p12){
odd_total = array_1[0] + array_1[2] + array_1[4] + array_1[6] + array_1[8] + array_1[10] + array_1[12];
printf("The sum of the odd numbers: %d\n", odd_total);
return;
}
int total (int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, int p9, int p10, p11, p12){
total_all = odd_total + even_total;
printf("The total of the numbers is: %d\n", total_all);
return;
}
現在說總的偶數和奇數(total_all)是18.我將如何分割起來,這樣array_2 [1]爲1和array_2 [2 ]是8?
偶數和奇數的總數是'18'。 **'array_1'和'array_2'的總和分別是'1'和'8' ** – jrd1 2013-03-18 03:44:59
@ jrd1也許他想把18的數字分成1和8嗎? – Patashu 2013-03-18 03:45:39
@Patashu,我不知道! – jrd1 2013-03-18 03:46:07