string
的用法string s(int n,'*')
可以控制重复字符形成一个string
string s.size()
返回string
长度
例 输入名字裱框
#include <iostream> #include <string> using namespace std; int main() { cout << "Please enter your name:"; string name; cin >> name; const string greeting = "Hello " + name + "!"; const string space(greeting.size(), ' '); const string fill(greeting.size()+2, '*'); cout << fill << endl; cout << '*' << space << '*' << endl; cout << '*' << greeting << '*' << endl; cout << '*' << space << '*' << endl; cout << fill << endl; system("pause"); return 0; }
string的用法
最新推荐文章于 2023-06-29 09:29:39 发布