The string is invalid if it contains any character other than '(' and ')'. Statement Sample Input 1:
()()(
Sample Output 1: yes
Sample Input 2: (()()
Sample Output 2: no
Sample Input 3: (((&))
Sample Output 3: invalid
What are the required conditions to be filled in appropriate looping statement to run the program.[Bold]
#include<stdio.h>
#include<string.h>
int main(){
char a[100];
int i=0,j=0,f=0;
gets(a);
while**()**
{
if**()**
{
f=1;
break;
}
i++;
}
i=0;
if()
{
while**()**
{
if**()**
{
j=1;
break;
}
i++;
}
}
if**()**
print("no");
else if()
print("yes");
else
print("invalid");
return 0;
}
Aucun commentaire:
Enregistrer un commentaire