chapter2-24.cpp

来自「大量程序实例」· C++ 代码 · 共 25 行

CPP
25
字号
//文件名:CHAPTER2-24.cpp
#include<string>
#include <iostream>
using namespace std;
int main()
 {
   string test;
   while(test.empty() ||  test.size() <= 5)
   {
     cout << "Type a string between 5 and 100 characters long. "
          << endl;
     cin >> test;
   }
 cout << "Changing the third character from " << test[2] << " to * " << endl;
   test[2] = '*';
   cout << "now its: " << test << endl << endl;
   cout << "Identifying the middle: ";
   test.insert(test.size() / 2, "(the middle is here!)");
   cout << test << endl << endl;
   cout << "I didn't like the word 'middle',so instead,I'll say:"<< endl;
   test.replace(test.find("middle",0), 6, "center");
   cout << test << endl; 
   return 0;
 }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?