L1-062 幸運彩票 分數 15

Frodnx發表於2024-08-10
// 4'56"
#include <bits/stdc++.h>
using namespace std;
bool func(string s)
{
    int sum1 = 0, sum2 = 0;
    for(int i = 0; i <= 2; ++ i)
        sum1 += s[i] - '0';
    for(int i = 3; i <= 5; ++ i)
        sum2 += s[i] - '0';
    if(sum1 == sum2) return true;
    return false;
}
int main()
{
    int n;
    cin >> n;
    for(int i = 1; i <= n; ++ i)
    {
        string s;
        cin >> s;
        if(func(s)) cout << "You are lucky!";
        else cout << "Wish you good luck.";
        if(i != n) cout << endl;
    }
    return 0;
}

相關文章