#include<stdio.h>
#include<string.h>
int main()
{
int test,num[20],i,k,len,l,x,sum,ds,rem,b;
char c[30],ch;
double mod;
scanf("%d%c",&test,&ch);
for(b=1;b<=test;b++)
{
gets(c);
len=strlen(c);
k=1;
for(i=0;i<len;i++)
{
if(c[i]!=' ')
{
num[k++]=c[i]-48;
}
}
sum=0;
for(l=1;l<k;l++)
{
if(l%2==0)
{
sum=sum+num[l];
}
else
{ ds=0;
x=num[l]*2;
while(x!=0)
{
rem=x%10;
x=x/10;
ds=ds+rem;
}
sum=sum+ds;
}
}
mod=sum%10;
if(mod!=0)
printf("Invalid\n");
else
printf("Valid\n");
}
return 0;
}
#include<string.h>
int main()
{
int test,num[20],i,k,len,l,x,sum,ds,rem,b;
char c[30],ch;
double mod;
scanf("%d%c",&test,&ch);
for(b=1;b<=test;b++)
{
gets(c);
len=strlen(c);
k=1;
for(i=0;i<len;i++)
{
if(c[i]!=' ')
{
num[k++]=c[i]-48;
}
}
sum=0;
for(l=1;l<k;l++)
{
if(l%2==0)
{
sum=sum+num[l];
}
else
{ ds=0;
x=num[l]*2;
while(x!=0)
{
rem=x%10;
x=x/10;
ds=ds+rem;
}
sum=sum+ds;
}
}
mod=sum%10;
if(mod!=0)
printf("Invalid\n");
else
printf("Valid\n");
}
return 0;
}
No comments:
Post a Comment