蒟蒻求助:样例全过,结果全wa

P1055 [NOIP2008 普及组] ISBN 号码

RedLotus_Resolution @ 2022-07-06 22:28:43

#include<bits/stdc++.h>
using namespace std;
int aa[1001],bb[1001],cc[1001];
int main(){
    long long a,b,c,d,i=0,j=0,k=0,sa=0,sb=0,sc=0,sz=0,ii,jj,kk,aaa,bbb,ccc;
    scanf("%d-%3d-%5d-%c",&a,&b,&c,&d);
    aaa=a;
    bbb=b;
    ccc=c;
    if(a==0) sa=0,i=1;
    if(b==0) sb=0,j=1;
    if(c==0) sc=0,k=1;
    while(a>0){
        i++;
        aa[i]=a%10;
        a/=10;
    }
    ii=i;
    while(b>0){
        j++;
        bb[j]=b%10;
        b/=10;
    }
    jj=j;
    while(c>0){
        k++;
        cc[k]=c%10;
        c/=10;
    }
    kk=k;
    for(int x=ii;x>=1;x--){
        sa+=aa[x]*(ii+1-x);
    }
    for(int y=jj;y>=1;y--){
        sb+=bb[y]*(jj+ii+1-y);
    }
    for(int z=kk;z>=1;z--){
        sc+=cc[z]*(jj+ii+kk+1-z);
    }
    sz=sa+sb+sc;
    if(d>='0'&&d<='9'&&sz%11==d-'0'){
        cout<<"Right";
        return 0;
    }
    else if(sz%11==10&&d=='X'){
        cout<<"Right";
    } 
    else if(sz%11==10&&d!='X'){
        printf("%d-%3d-%5d-%c",aaa,bbb,ccc,'X');
    }
    else if(d>='0'&&d<='9'&&sz%11!=d-'0'){
        printf("%d-%3d-%5d-%d",aaa,bbb,ccc,sz%11);
    }//这几行顺序比较乱 
    return 0;
}

by zac0425 @ 2022-07-07 21:16:31

解释一下这些变量代表什么


by writer @ 2022-07-08 15:13:02

顺序很乱,说一下自己的思路


by monalisa_K @ 2022-07-09 21:19:21

写的很杂乱,变量看不懂


|