解法一、陣列
✅ 完整代碼
評分結果(參考) : AC (2ms, 344KB)
#include <bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int a, b, s;
cin >> a >> b;
s = (a*2+b)%3;
vector<string> v = {"普通", "吉", "大吉"};
cout << v[s];
return 0;
}
解法二、switch case
✅ 完整代碼
#include <bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int a, b, s;
cin >> a >> b;
s = (a*2+b)%3;
switch(s){
case 0: cout << "普通"; break;
case 1: cout << "吉"; break;
case 2: cout << "大吉"; break;
}
return 0;
}