Skip to content

Instantly share code, notes, and snippets.

@ruyut
Created March 27, 2019 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruyut/2ee7b29f3ae387cf407ba6749177aa1a to your computer and use it in GitHub Desktop.
Save ruyut/2ee7b29f3ae387cf407ba6749177aa1a to your computer and use it in GitHub Desktop.
//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