Page 2 of 2

Re: 10931 i can't understand why WA!!!

Posted: Wed Apr 11, 2012 11:56 pm
by brianfry713
main should return int.
You have while(r>0) and r is uninitialized.

Re: 10931 i can't understand why WA!!!

Posted: Thu Apr 12, 2012 12:08 am
by cse.mehedi
:D

Re: 10931 - Parity (why compile error)

Posted: Tue Oct 23, 2012 6:37 pm
by Nahian37
#include<cstdio>
#include<cstdlib>
#include<cstring>
int main()
{
long long int k,i,j,d,c,n;
char a[1000000];
while(scanf("%lld",&n)==1&&n!=0)
{
c=0;
j=0;
while(n!=0)
{
d=n%2;
a[j]=d+48;
n=n/2;
j++;
}

for(i=0;a!=NULL;i++)
{
if(a=='1')
{
c++;
}
}
strrev(a);
printf("The parity of %s is %lld (mod 2).\n",a,c);
memset(a,0,sizeof a);

}
return 0;
}

Re: 10931 - Parity

Posted: Tue Oct 23, 2012 10:30 pm
by brianfry713
Check My Submissions and you can see the reason for your compile error.