2019年天梯赛-全国总决赛-L1-062 幸运彩票 (15 分)

题目链接:https://pintia.cn/problem-sets/994805046380707840/problems/1111914599412858883

题目大意:给一个6位数,分别求出前三位的和、后三位的和。判断是否相等。

#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
using namespace std;

int main(){
    int n;
    cin >> n;
    while(n--){
        int t;
        cin >> t;
        int q=t%10+t/10%10+t/100%10;
        int h=t/1000%10+t/10000%10+t/100000%10;
        if(q==h){
            cout << "You are lucky!\n";
        }else{
            cout << "Wish you good luck.\n";
        }
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_26122455/article/details/88929147