Skip to content

Instantly share code, notes, and snippets.

@ruyut
Created March 27, 2019 16:17
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/d1a461909b71ddc0c26ca58d47596f53 to your computer and use it in GitHub Desktop.
Save ruyut/d1a461909b71ddc0c26ca58d47596f53 to your computer and use it in GitHub Desktop.
//805-1
#include<stdlib.h>
#include<stdio.h>
int main() {
int arr[3][4], i, j, tot = 0;//宣告arr為整數二維陣列
for (i = 0; i<3; i++) {//0,1,2
printf("請輸入四個數字(數字之間請以空白為間隔):");
for (j = 0; j<4; j++) {//控制行
scanf("%d", &arr[i][j]);//把整數存入arr陣列的記憶體位址中
tot += arr[i][j];//把每個輸入的數都加到tot中(計算總合)
}
printf("\n");
}
for (i = 0; i<3; i++) {
for (j = 0; j<4; 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