Posted: Wed Jun 13, 2007 4:45 pm
What's wrong with my code!!!
#include <stdio.h>
#include <string.h>
int t, l, i, len, M, E, x, y, z;
char s[1001];
bool b;
int main()
{
scanf("%d", &t);
for (l = 0; l < t; l++)
{
scanf("%s", &s);
b = 1;
M = 0;
E = 0;
len = strlen(s);
for (i = 0; i < len; i++)
{
if (s != '?' && s != 'M' && s != 'E') b = 0;
if (s == 'M') M++;
if (s == 'E') E++;
}
if (M != 1) b = 0;
if (E != 1) b = 0;
i = 0;
len = strlen(s);
x = 0;
while ((s == '?') && (i < len)) i++, x++;
if (x == 0) b = 0;
if (s == 'M') i++; else b = 0;
y = 0;
while ((s == '?') && (i < len)) i++, y++;
if (y == 0) b = 0;
if (s == 'E') i++; else b = 0;
z = 0;
while ((s == '?') && (i < len)) i++, z++;
if (z == 0) b = 0;
if (z > 0 && x > 0 && y > 0 && M == 1 && E == 1) b = 1;
if (b)
puts("theorem");
else
puts("no-theorem");
}
return 0;
}
#include <stdio.h>
#include <string.h>
int t, l, i, len, M, E, x, y, z;
char s[1001];
bool b;
int main()
{
scanf("%d", &t);
for (l = 0; l < t; l++)
{
scanf("%s", &s);
b = 1;
M = 0;
E = 0;
len = strlen(s);
for (i = 0; i < len; i++)
{
if (s != '?' && s != 'M' && s != 'E') b = 0;
if (s == 'M') M++;
if (s == 'E') E++;
}
if (M != 1) b = 0;
if (E != 1) b = 0;
i = 0;
len = strlen(s);
x = 0;
while ((s == '?') && (i < len)) i++, x++;
if (x == 0) b = 0;
if (s == 'M') i++; else b = 0;
y = 0;
while ((s == '?') && (i < len)) i++, y++;
if (y == 0) b = 0;
if (s == 'E') i++; else b = 0;
z = 0;
while ((s == '?') && (i < len)) i++, z++;
if (z == 0) b = 0;
if (z > 0 && x > 0 && y > 0 && M == 1 && E == 1) b = 1;
if (b)
puts("theorem");
else
puts("no-theorem");
}
return 0;
}