코테 문제 풀이/정올

580 : 함수2 - 자가진단2

waVwe 2020. 11. 1. 20:59
728x90
반응형

C

#include<stdio.h>

int sort(int a,int b){
  if(b<1){
    return 0;
  }
  switch(a)
  {
    case 1:
    case 3:
    case 5:
    case 7:
    case 8:
    case 10:
    case 12:
      return b<=31? 1:0;
    case 2:
      return b<=29? 1:0;
    default:
      return b<=30? 1:0;
  }
}

int main(){
  int a,b;
  scanf("%d%d",&a,&b);
  if(sort(a,b)==0){
    printf("BAD!");
  }
  else{
    printf("OK!");
  }
}

 

 

 

출처 : www.jungol.co.kr/theme/jungol/mypage.php?user_id=tuberose39

728x90
반응형