标签:style blog color io os ar sp div c
1.判断是否是闰年(多行输入)
分析:是闰年的条件:year%4==0 && year%100 !=0 或者 year%400==0
#include <iostream> using namespace std; int main(){ int year; bool isLeapYear; cout<<"Enter the year:"<<endl; cin>>year; while(year!=-1){ isLeapYear = ((year%400==0)||(year%100!=0 && year%4==0 )); if(isLeapYear) cout<<year<<" is a leap year"<<endl; else cout<<year<<" is not a leap year"<<endl; cout<<"Enter the year:"<<endl; cin>>year; } return 0; }
标签:style blog color io os ar sp div c
原文地址:http://www.cnblogs.com/yanyangbyou/p/3998301.html