//// main.cpp// 2_1//// Created by T.P on 2018/2/28.// Copyright © 2018年 T.P. All rights reserved.//#include #include using namespace std;int main() { cout<<"Hello!"< =60? "pass":"fail")< <
//// main.cpp// 2_2//// Created by T.P on 2018/3/4.// Copyright © 2018年 T.P. All rights reserved.////判断闰年//:闰年可以被4整除而不能被100整除,或者能被400整除。//表达式((year%4==0&&year%100!=0)||(year%400==0))#include #include //包含IO类库操作符using namespace std; //没写 using namespace std; 用 std::cout //写了 using namespace std; 用 cout 就可以了。int main(int argc, const char * argv[]) { // insert code here... //std::cout << "Hello, World!\n"; int year; bool isLeapYear; cout<<"Enter the year:"; cin>>year; isLeapYear=((year%4==0&&year%100!=0)||(year%400==0)); if(isLeapYear) cout< <<"is a leap year"<
//// main.cpp// 2_3//// Created by T.P on 2018/3/4.// Copyright © 2018年 T.P. All rights reserved.////比较两个数的大小#include #include using namespace std;int main(int argc, const char * argv[]) { int x,y; cout<<"Please Enter x and y : "; cin>>x>>y; cout< y) cout << "x>y"; else cout << "x
//// main.cpp// 2_4//// Created by T.P on 2018/3/4.// Copyright © 2018年 T.P. All rights reserved.////输入一个0~6的整数,转换成星期输出#include #include using namespace std;int main(int argc, const char * argv[]) { // insert code here... //std::cout << "Hello, World!\n"; int day; cin>>day; switch (day) { case 0: cout<<"Sunday"; break; case 1: cout<<"Monday"; break; case 2: cout<<"Tuesday"; break; case 3: cout<<"Wednesday"; break; case 4: cout<<"thursday"; break; case 5: cout<<"Friday"; break; case 6: cout<<"Saturday"; break; default: cout<<"Day out of range Sunday...Saturday"; break; } cout<