题目描述:
输入一个正整数 X ,输出第 X 月的天数。(不需要考虑闰年,都是平年)
输入格式:
一个整数 X 。
输出格式:
第 X 月的天数。
C++代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
int x;
cin>>x;
if(x==1||x==3||x==5||x==7||x==8||x==10||x==12) cout<<31<<endl;
if(x==4||x==6||x==9||x==11) cout<<30<<endl;
if(x==2) cout<<28<<endl;
return 0;
}
C语言代码:
#include<stdio.h>
#include<stdlib.h>
int main(){
int x;
scanf("%d",&x);
if(x==1||x==3||x==5||x==7||x==8||x==10||x==12) printf("31\n");
if(x==4||x==6||x==9||x==11) printf("30\n");
if(x==2) printf("28\n");
return 0;
}