算法竞赛入门经典第五章例题5-3 Andy's First Dictionary UVA - 10815

本文提供了一段用于解决UVA-10815编程问题的C++代码实现。该代码利用了字符串流和集合来处理输入,并输出所有不重复的单词。适合于学习字符串处理和集合使用的初学者。

https://vjudge.net/problem/UVA-10815

#include<iostream>
#include<sstream>
#include<set>
#include<string>
using namespace std;
#pragma warning(disable:4996)
const int maxn = 30;

int main()
{
#ifdef _DEBUG
    //freopen("in", "rb", stdin);
    //freopen("out", "wb", stdout);
#endif // _DEBUG
    set<string> all;
    string s;
    while (cin >> s) {
        for (auto &x : s) {
            if (isalpha(x)) x = tolower(x);
            else x = ' ';
        }
        stringstream ss(s);
        while (ss >> s) all.insert(s);
    }
    for (auto x : all)
        cout << x << endl;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值