Copyright (c) 2016,烟台大学计算机学院.
All rights reserced.
文件名称:test.cpp
作者 :秦通
完成日期:2016.3.15
版本号 :VC++6.0
问题描述:输入年份和月份,输出本月有几天
输入描述:两个数:年份year,月份month.
#include<iostream>
using namespace std;
int main()
{
int year,month;
cin>>year>>month;
if(month==2)
{
if(year%4==0)
cout<<"本月29天";
else cout<<"本月28天";
}
else if(month==4||month==6||month==9||month==11)
cout<<"本月30天";
else cout<<"本月31天";
return 0;
}
运行结果:
知识点总结:从这个程序中,进一步巩固了对简单程序结构的认识,也学会了利用输入的结果的方法。
学习心得:一开始写程序,将endl后面的分号写成了汉字标点,于是一番纠结。等把这些错误积累起来。遇到错误不慌张在错误中成长,我能行!