zoukankan      html  css  js  c++  java
  • hdu 1113 Word Amalgamation

    原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1113

    字符串简单题:

    stl水过

    如下:

     1 #include<algorithm>
     2 #include<iostream>
     3 #include<cstdlib>
     4 #include<cstring>
     5 #include<cstdio>
     6 #include<string>
     7 #include<map>
     8 #include<set>
     9 using std::set;
    10 using std::map;
    11 using std::sort;
    12 using std::string;
    13 using std::next_permutation;
    14 set<string> rec;
    15 int _main(){
    16 #ifdef LOCAL
    17     freopen("in.txt", "r", stdin);
    18     freopen("out.txt", "w+", stdout);
    19 #endif
    20     int c = 0;
    21     char buf[10], tmp[10];
    22     while (~scanf("%s", buf) && c != 2){
    23         if (!c && strcmp(buf, "XXXXXX") != 0) rec.insert(buf);
    24         else if (0 == strcmp(buf, "XXXXXX")) c++;
    25         else {
    26             int flag = 0, n = strlen(buf);
    27             strcpy(tmp, buf);
    28             sort(tmp, tmp + n);
    29             do{
    30                 if (rec.count(tmp) != 0) flag = 1, printf("%s
    ", tmp);
    31             } while (next_permutation(tmp, tmp + n));
    32             if (!flag)  printf("NOT A VALID WORD
    ", tmp);
    33             printf("******
    ");
    34         }
    35     }
    36     return 0;
    37 }
    View Code
    By: GadyPu 博客地址:http://www.cnblogs.com/GadyPu/ 转载请说明
  • 相关阅读:
    代码面试最常用的10大算法
    ant google compiler 压缩
    美工资源
    面试题
    validate表单验证插件
    laypage分页
    layer弹出框小结
    Thymeleaf
    webApp开发
    grunt自动化构建工具
  • 原文地址:https://www.cnblogs.com/GadyPu/p/4485256.html
Copyright © 2011-2022 走看看