673 - parenthesis balance

All about problems in Volume VI. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

673 - parenthesis balance

Postby mehrab » Sun Jul 04, 2010 11:35 am

i'm getting wrong answer for the following code ... any help would be appreciated....
is my logic correct for the following code...

[code]//parenthesis balance
#include <stdio.h>

int main()
{
char ch[128];
int cas,i,j,a,b;
int sum1,sum2;

scanf("%d",&cas);

for(i=0;i<cas;i++)
{
scanf("%s",&ch);

sum1=0,sum2=0;

for(j=0;ch[j]!='\0';j++)
{
if(ch[j]>90)
sum1+=ch[j];
else
sum2+=ch[j];
}
if(sum1%2==0)
a=1;
else
a=0;


if(sum2<81)
{
if(sum2==0)
b=1;
else
b=0;
}

else
{
if(sum2%81==0)
b=1;
else
b=0;
}


if(a*b==1)
printf("Yes\n");
else
printf("No\n");

}
return 0;
}[code]
mehrab
New poster
 
Posts: 10
Joined: Sat Jul 03, 2010 3:04 pm

Re: 673 - parenthesis balance

Postby sohel » Sun Jul 04, 2010 10:45 pm

Have you looked at other discussion related to this problem. Like, viewtopic.php?f=7&t=12707
Don't create a new thread for a problem that already exists!
User avatar
sohel
Guru
 
Posts: 862
Joined: Thu Jan 30, 2003 5:50 am
Location: University of Texas at San Antonio


Return to Volume VI

Who is online

Users browsing this forum: No registered users and 0 guests