namereq

学年ごとの合計

Jun 27th, 2018
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.38 KB | None | 0 0
  1. #include<stdio.h>
  2. int main(void)
  3. {
  4.     int t[4][3],i,j;
  5.     for(i=0;i<4;i++){
  6.         for(j=0;j<2;j++){
  7.             printf("%d年%d組の学生数を入力してください:",i+1,j+1);
  8.             scanf("%d",&t[i][j]);
  9.         }
  10.         t[i][2]=t[i][0]+t[i][1];
  11.     }
  12.     printf("1組 2組 学年ごとの合計\n");
  13.     for(i=0;i<4;i++){
  14.         printf("%d年生 %d %d %d\n",i+1,t[i][0],t[i][1],t[i][2]);
  15.     }
  16.     return 0;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment