This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//805-2 | |
#include<stdlib.h> | |
#include<stdio.h> | |
int main() { | |
int arr[5][2], i, j, tot = 0;//宣告arr為整數二維陣列 | |
for (i = 0; i<5; i++) { | |
printf("請輸入兩個數字(數字之間請以空白為間隔):"); | |
for (j = 0; j<2; j++) { | |
scanf("%d", &arr[i][j]);//把整數存入arr陣列的記憶體位址中 | |
tot += arr[i][j];//把每個輸入的數都加到tot中(計算總合) | |
} | |
printf("\n"); | |
} | |
for (i = 0; i<5; i++) { | |
for (j = 0; j<2; j++) | |
printf("%d ", arr[i][j]);//列印出變數 | |
printf("\n"); | |
} | |
printf("sum:%d\n", tot); | |
system("PAUSE");//停住等待使用者按下任意一個按鍵 | |
return 0;//跳出 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment