fork(1) download
  1. #include <stdio.h>
  2. #define MONTHS 12
  3. int main(void)
  4. {
  5. int days[MONTHS]={31,28,31,30,31,30,31,31,30,31,30,31};
  6. int month;
  7. do{
  8. printf("Input a month:");
  9. scanf("%d", &month);
  10. }while(month < 1 || month > 12); /* 处理不合法数据的输入 */
  11. printf("The number of days is %d\n", days[month-1]);
  12. return 0;
  13. }
Success #stdin #stdout 0s 544KB
stdin
2
stdout
Input a month:The number of days is 28