MY name is ruhul amin

ISLAMIC UNIVERSITY OF KUSHTIA

Sunday, March 3, 2013

uva solve problem 11743 - Credit Check

#include<stdio.h>
int main()
{
    char a[100];
    int i,j,k,m,s,sum,result,t,n,c[100],d,x;
    while(scanf("%d",&n)!=EOF)
    {
        for(i=1;i<=n;i++)
        {
            s=0;
            d=0;
            getchar();
            for(j=0;j<19;j++)
            {
            scanf("%c",&a[j]);
            }
            t=0;
            for(k=0;k<19;k=k+2)
            {
                if(a[k]==' ')
                k++;
                c[t]=(a[k]-48)*2;
                t++;
            }
            for(x=0;x<t;x++)
            {
                while(c[x]!=0)
                {
                    s=s+(c[x]%10);
                    c[x]=c[x]/10;
                }
            }
            for(m=1;m<19;m=m+2)
            {
                if(a[m-1]==' ')
                m=m+1;
                d=d+(a[m]-48);
            }
            sum=s+d;
            result=sum%10;
            if(result==0)
            printf("Valid\n");
            else
            printf("Invalid\n");
        }
    }
    return 0;
}

No comments:

Post a Comment