题解 | ZOJ问题

ZOJ问题

https://www.nowcoder.com/practice/e132f7aa63bb430494db3644b8ffa860

我寻思题目也没说z前面o的数量乘以z和j之间o的数量等于j后面o的数量啊?

#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <string>
using namespace std;

int main() {
    char str[1001];
    while (scanf("%s", str) != EOF) {
        string list = str;
        // z和j所在字符串中的下标
        int pos1 = list.find('z');
        int pos2 = list.find('j');

        string list_1 = list.substr(0, pos1);
        string list_2 = list.substr(pos1 + 1, pos2 - pos1 - 1);
        string list_3 = list.substr(pos2+1);

        // z前面o的数量乘以z和j之间o的数量等于j后面o的数量
        int len_1 = list_1.size();
        int len_2 = list_2.size();
        if (!len_2) {
            printf("Wrong Answer\n");
            break;
        }
        int len_3 = list_3.size();
        if (len_1 * len_2 == len_3) {
            printf("Accepted\n");
        }
        else {
            printf("Wrong Answer\n");
        }

    }
    return 0;
}
全部评论

相关推荐

醉蟀:你不干有的是人干
点赞 评论 收藏
分享
06-12 17:07
沈阳大学 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务