/*判断是工作日还是周末*/
#include <iostream>
using namespace std;
int main()
{
int i;
cout << "输入一个1-7之间的整数; ";
do{
cin >> i;
if(i<1 || i>7)
cout << "数据错误!请重新输入一个1-7之间的整数: ";
}while(i<1 || i>7);
switch(i){
case 1:
case 2:
case 3:
case 4:
case 5:
cout << "workday. Let‘s work hard";
break;
default: cout << "weekend. Let‘s have a rest";
break;
}
return 0;
}
/*将一个数倒过来(C++)*/
#include <iostream>
using namespace std;
int main()
{
int i, j, m=0;
cout << "请输入一个整数:";
cin >> i;
do{
j = i%10;
i = i/10;
m = m*10 + j;
} while(i != 0);
cout << "倒过来的数为: " << m << endl;
return 0;
}