10391 - Compound Words (UVA)

题目链接如下:

Online Judge

代码如下:

cpp 复制代码
#include <iostream>
#include <string>
#include <vector>
#include <set>
// #define debug

int main(){
    #ifdef debug
    freopen("0.txt", "r", stdin);
    freopen("1.txt", "w", stdout);
    #endif
    std::string word;
    std::vector<std::string> vec;
    std::set<std::string> st;
    while (std::cin >> word){
        vec.push_back(word);
        st.insert(word);
    }
    for (int i = 0; i < vec.size(); ++i){
        for (int j = 1; j < vec[i].size(); ++j){
            if(st.count(vec[i].substr(0, j)) && st.count(vec[i].substr(j))){
                std::cout << vec[i] << std::endl;
                break;
            }
        }
    }
    #ifdef debug
    fclose(stdin);
    fclose(stdout);
    #endif
    return 0;
}
相关推荐
2501_9411117718 分钟前
C++代码移植性设计
开发语言·c++·算法
yy_xzz1 小时前
【OpenCV + VS】C++实现动态下雪特效
c++·人工智能·opencv
橘子真甜~1 小时前
C/C++ Linux网络编程5 - 网络IO模型与select解决客户端并发连接问题
linux·运维·服务器·c语言·开发语言·网络·c++
2501_941111462 小时前
C++中的原型模式
开发语言·c++·算法
慢慢向上的蜗牛2 小时前
微软vcpkg包管理工具如何使用?
c++·microsoft·vcpkg·跨平台编译
wangjialelele2 小时前
详解mysql命令行操作与语言链接
c语言·数据库·c++·mysql·oracle
江塘3 小时前
机器学习-决策树多种生成方法讲解及实战代码讲解(C++/Python实现)
c++·python·决策树·机器学习
初见无风4 小时前
4.4 Boost库工具类assign 的使用
开发语言·c++·boost
月夜的风吹雨4 小时前
【C++ STL容器适配器】:解密Stack、Queue与Priority Queue的设计智慧
开发语言·c++·stl·优先级队列··队列·适配器
二川bro4 小时前
第48节:WebAssembly加速与C++物理引擎编译
java·c++·wasm