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

Posted:

**Wed Apr 11, 2012 11:56 pm**main should return int.

You have while(r>0) and r is uninitialized.

You have while(r>0) and r is uninitialized.

The UVa Online Judge board

https://uva.onlinejudge.org/board/

https://uva.onlinejudge.org/board/viewtopic.php?f=32&t=10099

Page **2** of **2**

Posted: **Wed Apr 11, 2012 11:56 pm**

main should return int.

You have while(r>0) and r is uninitialized.

You have while(r>0) and r is uninitialized.

Posted: **Thu Apr 12, 2012 12:08 am**

Posted: **Tue Oct 23, 2012 6:37 pm**

#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;

}

#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

{

if(a

{

c++;

}

}

strrev(a);

printf("The parity of %s is %lld (mod 2).\n",a,c);

memset(a,0,sizeof a);

}

return 0;

}

Posted: **Tue Oct 23, 2012 10:30 pm**

Check My Submissions and you can see the reason for your compile error.