zoukankan      html  css  js  c++  java
  • hdu1113大水题

    /*
     * hdu1113/win.cpp
     * Created on: 2013-6-1
     * Author    : ben
     */
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <cmath>
    #include <ctime>
    #include <iostream>
    #include <algorithm>
    #include <queue>
    #include <set>
    #include <map>
    #include <stack>
    #include <string>
    #include <vector>
    #include <deque>
    #include <list>
    #include <functional>
    #include <numeric>
    #include <cctype>
    using namespace std;
    const int MAXN = 105;
    
    string dict[MAXN];
    int N = 0;
    
    inline bool judge(string s, const char* str) {
        int len = strlen(str);
        if(len != s.length()) {
            return false;
        }
        char s1[50], s2[50];
        strcpy(s1, s.c_str());
        strcpy(s2, str);
        sort(s1, s1 + len);
        sort(s2, s2 + len);
        for(int i = 0; i < len; i++) {
            if(s1[i] != s2[i]) {
                return false;
            }
        }
        return true;
    }
    
    int main() {
    #ifndef ONLINE_JUDGE
        freopen("data.in", "r", stdin);
    #endif
        char str[30];
        while(scanf("%s", str) == 1) {
            if(strcmp(str, "XXXXXX") == 0) {
                break;
            }
            dict[N++] = string(str);
        }
        sort(dict, dict + N);
        while(scanf("%s", str) == 1) {
            if(strcmp(str, "XXXXXX") == 0) {
                break;
            }
            bool flag = false;
            for(int i = 0; i < N; i++) {
                if(judge(dict[i], str)) {
                    printf("%s\n", dict[i].c_str());
                    flag = true;
                }
            }
            if(!flag) {
                puts("NOT A VALID WORD");
            }
            puts("******");
        }
        return 0;
    }
  • 相关阅读:
    矩形覆盖
    跳台阶与变态跳台阶
    有几个PAT【*】
    找零钱
    有理数的四则运算
    旧键盘打字
    查验身份证
    完美数列【置顶】
    旧键盘
    超简单webservice实例
  • 原文地址:https://www.cnblogs.com/moonbay/p/3111947.html
Copyright © 2011-2022 走看看