#32961: 好奇哪邊出錯了 部分錯誤


a0929654931@gmail.com (小さな恐竜)

學校 : 不指定學校
編號 : 178477
來源 : [219.85.227.241]
最後登入時間 :
2023-03-10 17:24:25
a020. 身分證檢驗 | From: [112.78.95.32] | 發表日期 : 2022-11-19 21:14

#include <iostream>
using namespace std;


int main(int argc, char** argv) {
    char name[10];
    int total=0;
    cin>>name;
    for(int i = 0 ,j=9; i<10;i++,j--){
        if(name[i]>64&&name[i]<91){
            if(name[i]=='W')
                total+=3+2*9;
            else if(name[i]=='X')
                total+=3;
            else if(name[i]=='Y')
                total+=12;
            else if(name[i]=='I')
                total+=3+4*9;
            else if(name[i]=='O')
                total+=3+5*9;
            else if(name[i]>79||name[i]<87)//P~V
                total+=2+(int(name[i])-77)*j;
            else if(name[i]=='Z')
                total+=3+3*9;
            else if(name[i]=='J')
                total+=1+8*9;
            else if(name[i]=='K')
                total+=1+9*9;
            else if(name[i]=='L')
                total+=2;
            else if(name[i]=='M')
                total+=2+1*9;
            else if(name[i]=='N')
                total+=2+2*9;
            else{
                int abc=int(name[i])-55;
                total+=(abc%10)*j;
                total+=1;
            }
            
        }
        else{
            total+=(int(name[i])-48)*j;
            if(j==1) j++;
        }
    }
    //cout<<total<<' '<<1+((int(name[0])-55)%10)*9<<' '<<int(name[0]);
    if(total%10)
        cout<<"fake";
    else
        cout<<"real";

 
#32969: Re: 好奇哪邊出錯了 部分錯誤


cges30901 (cges30901)

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


            else if(name[i]>79||name[i]<87)//P~V


||改成&&

 
#32970: Re: 好奇哪邊出錯了 部分錯誤


a0929654931@gmail.com (小さな恐竜)

學校 : 不指定學校
編號 : 178477
來源 : [219.85.227.241]
最後登入時間 :
2023-03-10 17:24:25
a020. 身分證檢驗 | From: [1.200.155.204] | 發表日期 : 2022-11-20 09:41


            else if(name[i]>79||name[i]<87)//P~V


||改成&&


AC了感謝!!!!

 
ZeroJudge Forum