zoukankan      html  css  js  c++  java
  • 华为OJ:字符串处理

     1 #include <iostream>
     2 #include <stdlib.h>
     3 #include <string>
     4 #include <sstream>
     5 #include <vector>
     6 using namespace std;
     7 
     8 int main()
     9 {
    10     string s;
    11     getline(cin, s);
    12     for (auto it = s.begin(); it != s.end(); it++)
    13     {
    14         if (!isalpha(*it))
    15             (*it) = ' ';
    16     }
    17 
    18     istringstream ss(s);
    19     string tmp;
    20     vector<string>ans;
    21     while (ss>>tmp)
    22     {
    23         tmp[0] = toupper(tmp[0]);
    24         ans.push_back(tmp);
    25         //tmp.clear();
    26     }
    27     (ans.back()).insert((ans.back()).end(), '.');
    28     for (auto it = ans.begin(); it != ans.end(); it++)
    29     {
    30         if (it == prev(ans.end()))
    31             cout << *it;
    32         else
    33             cout << *it << ' ';
    34     }
    35     system("pause");
    36     return 0;
    37 }
  • 相关阅读:
    uIP的ARP协议分析
    如何使函数不生成执行代码
    计算机网络基础
    [Hive
    [Hive
    [Hive
    [Hive
    [Hive
    [Hive
    [Hive
  • 原文地址:https://www.cnblogs.com/zhuruibi/p/11298395.html
Copyright © 2011-2022 走看看