不想用if的进来
2024-10-21 20:28:37
发布于:北京
3阅读
0回复
0点赞
第一种:
#include <bits/stdc++.h>
using namespace std;
int main(){
int day;
cin >> day;
if (day >= 8 || day <= 0){
cout << "no";
return 0;
}
string a[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
cout << a[day - 1];
return 0;
}
第二种:
#include <bits/stdc++.h>
using namespace std;
int main(){
int day;
cin >> day;
switch(day){
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;
case 7:
cout << "Sunday";
break;
default:
cout << "no";
break;
}
return 0;
}
这里空空如也
有帮助,赞一个