小编Ama*_*One的帖子

大写字母

我有一个小问题。我想利用字符串中的双字母大写。我设法编译了一个程序,但没有成功。

#include <iostream>
#include <cctype>
#include <string>

std::string::iterator function(
   std::string::const_iterator a, 
   std::string::const_iterator b,
   std::string::const_iterator e)
{
   for (; a < b; a++) 
   {
      if (*a == *(a + 1)) 
      {
         toupper(*a);
         toupper(*(a + 1));
      }
   }
}

int main()
{
   std::string in = "peppermint 1001 bubbles balloon gum", out(100, '*');
   auto e = function(in.cbegin(), in.cend(), out.begin());

   int n = e - out.begin();
   std::string s = out.substr(0, n);
   bool b = (s == "pePPermint 1001 buBBles baLLOOn gum");
   std::cout << std::boolalpha …
Run Code Online (Sandbox Code Playgroud)

c++ algorithm iterator loops stdstring

2
推荐指数
1
解决办法
94
查看次数

标签 统计

algorithm ×1

c++ ×1

iterator ×1

loops ×1

stdstring ×1