SDUT 1160 某年某月的天数

来源:互联网 发布:艾瑞网数据 编辑:程序博客网 时间:2024/06/08 14:54

Problem Description

输入年和月,判断该月有几天?

Input

输入年和月,格式为年\月。

Output

输出该月的天数。

Example Input

2009\1

Example Output

31


答案:

#include<iostream>#include<stdio.h>using namespace std;int main() {int a[13] = {31, 28, 31, 30, 31, 30, 31, 31,30, 31, 30, 31};int b[13] = {31, 29, 31, 30, 31, 30, 31, 31,30, 31, 30, 31};int c, d;char e;cin>> c >> e >> d;//定义一个字符串来存储输入的"\"if(c % 4 == 0 && c % 100 != 0 || c % 400 ==0)cout<< b[d - 1]<<endl;elsecout<< a[d - 1]<<endl;return 0;}


原创粉丝点击