getline(cin,str1);//字符串的行输入cout<<str1<<endl;//2.string类的构造函数string str2="aaaaa";//最简单的字符串初始化cout<<str2<<endl;char*s="bbbbb";stringstr3(s);//用c字符串s初始化cout<<str3<<endl;charch='c';stringstr4(5,ch);//用n个字符ch初始化cout<<str4<<endl;//3....
#include<iostream>#include<string>using namespace std; int main() { string t = "15:30:28"; // 1 5 : 3 0 : 2 8 // 0 1 2 3 4 5 6 7 string h = t.substr(0, 2); string m = t.substr(3, 2); string s = t.substr(6); cout << h << ' ' << m << ' ' << ...