// 浙大10机试
// ZOJ问题
// 第一次代码没有考虑j在前z在后的问题
// 第二次修正
#include <stdio.h>
#include <string.h>
bool Judge(char s[])
{
int na=0, nb=0,nc=0;
int i=0, len = strlen(s);
while(s[i] != 'z')
{
na++;
i++;
}
i++;
while(s[i] != 'j')
{
nb++;
i++;
}
i++;
while(s[i] != '\0')
{
nc++;
i++;
}
if(na == 0 && nc == 0 && nb>0)
{
return true;
}
else if(na>0 && nc>0 && na*nb == nc)
{
return true;
}
else
{
return false;
}
}
int main()
{
#ifdef ONLINE_JUDGE
#else
freopen("E:\\in.txt", "r", stdin);
#endif
char s[1005];
while(scanf("%s", s) != EOF)
{
printf("%s\n", Judge(s) ? "Accepted" : "Wrong Answer");
}
return 0;
}
//-------------------------------------------
#include <stdio.h>
#include <string.h>
bool Judge(char s[])
{
int na=0, nb=0,nc=0;
int i=0, len = strlen(s);
while(s[i] == 'o')
{
na++;
i++;
}
if(s[i] != 'z')
{
return false;
}
else
{
i++;
}
while(s[i] == 'o')
{
nb++;
i++;
}
if(s[i] != 'j')
{
return false;
}
else
{
i++;
}
while(s[i] == 'o')
{
nc++;
i++;
}
if(s[i] != '\0')
{
return false;
}
if(na == 0 && nc == 0 && nb>0)
{
return true;
}
else if(na>0 && nc>0 && na*nb == nc)
{
return true;
}
else
{
return false;
}
}
int main()
{
#ifdef ONLINE_JUDGE
#else
freopen("E:\\in.txt", "r", stdin);
#endif
char s[1005];
while(scanf("%s", s) != EOF)
{
printf("%s\n", Judge(s) ? "Accepted" : "Wrong Answer");
}
return 0;
}
九度:1006<ZOJ问题><规则,规律>
最新推荐文章于 2019-02-20 16:50:20 发布