#include<iostream>
using namespace std;
int main()
{
int n;
cin >> n;
switch (n)
{
case 0: cout <<"sunday" << endl; break;
case 1: cout << "monday" << endl; break;
case 2: cout << "tuseday" << endl; break; break;
case 3: cout << "wensday" << endl; break; break;
case 4: cout << "thursday" << endl; break; break;
case 5: cout << "friaday" << endl; break; break;
case 6: cout << "saturday" << endl; break; break;
default: break;
}
system("pause");
return 0;
}
using namespace std;
int main()
{
int n;
cin >> n;
switch (n)
{
case 0: cout <<"sunday" << endl; break;
case 1: cout << "monday" << endl; break;
case 2: cout << "tuseday" << endl; break; break;
case 3: cout << "wensday" << endl; break; break;
case 4: cout << "thursday" << endl; break; break;
case 5: cout << "friaday" << endl; break; break;
case 6: cout << "saturday" << endl; break; break;
default: break;
}
system("pause");
return 0;
}
本文展示了一个简单的C++程序,该程序通过输入一个整数(0-6),输出对应的星期名称。使用了switch-case语句来实现选择结构,并利用标准输入输出进行交互。
1万+

被折叠的 条评论
为什么被折叠?



