티스토리 뷰
11월 3째주 첫 코드리뷰
타일수 구하기
코드 예시
#include< stdio.h > int main() { int a, b,arest,brest, wtile,ptile; scanf("%d", &a); scanf("%d", &b); arest = a % 8; brest = b % 8; a /= 8; b /= 8; wtile = a*b; if (arest != 0) { if (brest == 0) { ptile = b; } else { ptile = a + b +1 ; } } else { if (brest == 0) { ptile = 0; } else { ptile = a; } } printf("The number of whole tiles is %d part tiles is %d", wtile,ptile); return 0; }
두번째 문제
캥거루
코드 예시
#include< iostream > using namespace std; int main(){ int a, b, c; cin >> a >> b >> c; int cha1, cha2; cha1 = b - a; cha2 = c - b; if (cha1 > cha2){ cout << cha1 - 1; } else{ cout << cha2 - 1; } return 0; }
댓글