求解!!!
查看原帖
求解!!!
996897
linyuxi2014楼主2024/6/3 13:33

本人0分代码:

#include <iostream>
#include <cmath>
using namespace std;

int trans(int n){
    if (n == 0)
        return 0;
    if (n == 1)
        return 7;
    n = n % 10 + n / 10;
    while (n > 9)
        n = n % 10 + n / 10;
    return n;
}

bool judge(int n){
    int ans = 0;
    int cnt = 1;
    while (n > 0){
        if (cnt % 2)
            ans += trans(n % 10) * pow(10, cnt - 1);
        else
            ans += n % 10 * pow(10, cnt - 1);
        n /= 10;
        cnt++;
    }
    return ans % 8 == 0;
}

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++)
        cin >> a[i];
    for(int i = 0; i < n; i++){
        if(judge(a[i]))
            cout << 'T' << endl;
        else
            cout << 'F' << endl;
    }
}

向各位大佬求解!!!

2024/6/3 13:33
加载中...