题目1006:ZOJ问题

来源:互联网 发布:霍尼韦尔净水器 知乎 编辑:程序博客网 时间:2024/05/16 10:33

#include <stdio.h>#include <string.h>char s[1001];int main(){        int a,b,c;        char *p;        while(scanf("%s",s)!=EOF){                if(!strcmp(s,"zoj")){printf("Accepted\n");continue;}   //条件一                 a=b=c=0;                p=s;                while(*p=='o'){a++;p++;}   //a为第一个z前o的个数                if(*p=='z'){                        p++;                        while(*p=='o'){b++;p++;}   //b为夹在z和j之间的o的个数                        if(*p=='j'){                                p++;                                while(*p=='o'){c++;p++;}   //c为j之后的o的个数                                if(!(*p) && b>0 && c==a*b){printf("Accepted\n");continue;}  //条件三                        }                }                printf("Wrong Answer\n");        }        return 0;}/**************************************************************    Problem: 1006    User: cust123    Language: C++    Result: Accepted    Time:10 ms    Memory:1020 kb****************************************************************/


0 0
原创粉丝点击