zju2010:ZOJ問題

http://ac.jobdu.com/problem.php?pid=1006

2010年浙江大學計算機及軟件工程研究生機試真題

#include <stdio.h>

char str[1005];
int main()
{
   int a,b,c,z,j,i;                 //a:z前面o的個數,b:zj間o的個數,c:j後面o的個數
   while (scanf("%s",str)!=EOF)
   {
	   a=0,b=0,z=0,j=0,c=0;
	   for(i=0;str[i]!='\0';i++)
	   {
		   if (str[i]=='o'&&z==0)
		   {
			   a++;
		   }
		   else if (str[i]=='z')
		   {
			   z++;
		   }
		   else if (str[i]=='o'&&j==0)
			{
				 b++;
			 }
			else if (str[i]=='j')
			{
				j++;
			}
			else if (str[i]='o')
			{
				c++;
			}
	   }
	   if ( z==1&&j==1&&( ( b==1&&(a==c) )||(b>1&&a*b==c ) ) )
	   {
		   printf("Accepted\n");
	   }
	   else
		   printf("Wrong Answer\n");
   }
   return 0;
}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章