Emp3r0r.egloos.com

Regular Admission Empire

포토로그



행렬의 덧셈 C

#include <stdio.h>
#define ROWS 3
#define COLS 3

int main(void) {
  int r,c;

  int A[ROWS][COLS] = {{1,0,0},{0,1,0},{0,0,1}};
  int B[ROWS][COLS] = {{1,0,0},{0,1,0},{0,0,1}};
  int C[ROWS][COLS];


  for(r=0;r<ROWS;r++){
    for(c=0;c<COLS;c++){
      C[r][c] =A[r][c]+B[r][c];
      printf("%d",C[r][c]);
      }
      printf("\n");
  }
  return 0;
}


덧글

댓글 입력 영역