Skip to content

Instantly share code, notes, and snippets.

@odiak
Created June 13, 2011 07:28
Show Gist options
  • Save odiak/1022422 to your computer and use it in GitHub Desktop.
Save odiak/1022422 to your computer and use it in GitHub Desktop.
hoge.c
#include <stdio.h>
int main (void) {
int a, n;
scanf("%d", &a);
switch(a) {
case 2 :
n = 28;
break;
case 4 :
case 6 :
case 9 :
case 11 :
n = 30;
break;
case 1 :
case 3 :
case 5 :
case 7 :
case 8 :
case 10 :
case 11 :
n = 31;
break;
default :
n = 0;
}
if (n) {
printf("%d\n", n);
} else {
printf("wrong input.\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment