#31309: 想問為什麼有兩個資測點沒有過?


helloliu19990612@gmail.com (Liu Hello)

學校 : 不指定學校
編號 : 193558
來源 : [111.249.12.200]
最後登入時間 :
2023-05-20 19:57:43
a020. 身分證檢驗 | From: [111.249.39.74] | 發表日期 : 2022-07-23 13:23

#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
using namespace std;

int main() {
    int num=0,total=0;
    int f = 8;
    string a;
    cin >> a;
    string alphabet= "ABCDEFGHJKLMNPQRSTUVWXYZIO";
        for (int c = 0; c < 26; c++)
        {
            if (a[0] == alphabet[c])
            {
                num = c + 10;
                break;
            }
    }
    total = (num / 10) + ((num % 10) * 9);
    for (int e = 1; e < a.length(); e++)
    {
        if (f == 0)
        {
            total += (a[e]-48);
        }
        else
        {
            total += (a[e]-48) * f;
        }
        f--;
    }
    if (total % 10 == 0)
    {
        cout << "real";
    }
    else if(total==0)
    {
        cout << "fake";
    }
    else 
    {
        cout << "fake";
    }
    return 0;
}

 
#31320: Re: 想問為什麼有兩個資測點沒有過?


cges30901 (cges30901)

學校 : 不指定學校
編號 : 30877
來源 : [101.136.203.77]
最後登入時間 :
2024-04-07 15:34:14
a020. 身分證檢驗 | From: [106.64.130.232] | 發表日期 : 2022-07-23 20:19


    string alphabet= "ABCDEFGHJKLMNPQRSTUVWXYZIO";


WXY順序錯了

 
ZeroJudge Forum