题解
2024-08-30 22:20:00
发布于:浙江
0阅读
0回复
0点赞
通过char数组存星期英文,再通过if语句进行判断,是程序达到题目要求
#include <iostream>
using namespace std;
int main() {
char str[7][10] = {"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"};
int n;
cin >> n;
if (n < 7 && n > 0) {
cout << str[n];
}
else {
n %= 7;
if (n == 0) n = 0;
cout << str[n];
}
return 0;
}
这里空空如也
有帮助,赞一个