本月有几天,亲
来源:互联网 发布:spark 大数据 股票 编辑:程序博客网 时间:2024/05/02 00:34
/* * Copyright (c) 2012, 烟台大学计算机学院 * All rights reserved. * 作 者:刘玉金* 完成日期:2012 年 10月 31日 * 版 本 号:v1.0 * 输入描述:年、月 * 问题描述:略* 程序输出:该月份有几天* 问题分析: 略 #include<iostream> using namespace std; int main() { int year, month, day; cout << "请输入年、月: "; cin >> year >> month; switch(month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: day = 31;break; case 4: case 6: case 9: case 11: day = 30; break; case 2: if(year%4==0 && year%100!=0) day = 29; else day =28; } cout<<year<<"年"<<month<<"月共有"<<day<<"天。"<<endl; return 0; }
运行结果: