打表法

dinosaurgy 2019-05-25 16:21:13 2019-05-25 16:22:17 17
#include<iostream>
#include<cstring>
using namespace std;
int x;
string c[7]={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
int main(void){
	cin>>x;
	if(x <= 7) {
	cout<<c[x-1]<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}

天知道为什么最后一个点错了。。。

{{ vote && vote.total.up }}

共 10 条回复

Even226 逗比
#include <iostream>
#include <string>

int main() {
    int day;
    std::cin >> day;

    std::string dayName;

    switch (day) {
        case 1:
            dayName = "Monday";
            break;
        case 2:
            dayName = "Tuesday";
            break;
        case 3:
            dayName = "Wednesday";
            break;
        case 4:
            dayName = "Thursday";
            break;
        case 5:
            dayName = "Friday";
            break;
        case 6:
            dayName = "Saturday";
            break;
        case 7:
            dayName = "Sunday";
            break;
        default:
            dayName = "No";
    }

    std::cout << dayName << std::endl;

    return 0;
}
gym14 氪佬

警告你:不能发答案!!!

root 站长

楼下正解,我去加强一下数据!

shuaige

第一个if条件应该再加一个x>=1

dinosaurgy

啪啪啪。。。

给楼下鼓掌

dinosaurgy

吾乃常山赵子龙是也!

dinosaurgy

。。。。。。忘做了

dinosaurgy

???高原是谁?

一座山么。。。

root 站长

话说你是高原么?

root 站长

最后一个点是 No,你做错了~