U E D R , A S I H C RSS

StuPId/김태진

#include <stdio.h>

int main ()
{
    int i,j,k,N,n,sum=1,Sce=1;
    int unr;
    char id[8],id2[8],ftr[8]={0};
    
    scanf("%d",&N);
    for(j=0;j<N;j++){
        sum=1;
        scanf("%s",id);
        if(id[6]=='\0') {
            n=6;
            ftr[0]=7;
            ftr[1]=3;
            ftr[2]=9;
            ftr[3]=7;
            ftr[4]=3;
            ftr[5]=9;
        }
        else {
            n=7;
            ftr[0]=9;
            ftr[1]=7;
            ftr[2]=3;
            ftr[3]=9;
            ftr[4]=7;
            ftr[5]=3;
            ftr[6]=9;
        }
        //6or7자리임을 알아냄
        for(i=0;i<n;i++){
            id2[i]=id[i]-'0'; // ?-0 == 15;
            if(id2[i]==15) unr=i;
        }
        
        for(i=0;sum%10!=0;i++){
            sum=0;
            id2[unr]=i;
            for(k=0;k<n;k++){
                sum+=id2[k]*ftr[k];
            }
        }
        id[unr]='0'+i-1;
        printf("Scenario #%d:\n",Sce);
        Sce++;
        printf("%s\n\n",id);

    
    }
    
    return 0;
}
코드가 좀 보기 싫게 생겼지만 아무튼 한번만에 accept!
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:28:08
Processing time 0.0078 sec