读入一段文本到 vector 对象,每个单词存储为 vector 中的一个元素。把 vector 对象中每个单词转化为大写字母。输出 vector 对象中转化后的元素,每八个单词为一行输出。
int main(void)
 {
 ?? ?string alphabet; string T_p; vector<string>count;
 ?? ?cout << "輸入文本 單輸入:結束" << endl;
 ?? ?while (cin >> alphabet)
 ?? ?{
 ?? ??? ?if (alphabet == ":")
 ?? ??? ??? ?break;
 ?? ??? ?count.push_back(alphabet);
 ?? ?}
 ?? ?while (getchar()!= '\n')
 ?? ??? ?continue;
 ?? ?for (vector<string>::size_type i = 0; i != count.size(); ++i)
 ?? ?{
 ?? ??? ?for (vector<int>::size_type i1 = 0; i1 != count[i].size(); ++i1)
 ?? ??? ??? ?cout << (char)(toupper(count[i][i1]));
 ?? ??? ?cout << " ";
 ?? ??? ?if (i == 7)
 ?? ??? ??? ?cout << "\n";
 ?? ?}
 ?? ?return 0;
 }
總結
以上是生活随笔為你收集整理的读入一段文本到 vector 对象,每个单词存储为 vector 中的一个元素。把 vector 对象中每个单词转化为大写字母。输出 vector 对象中转化后的元素,每八个单词为一行输出。的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: 小米创始人雷军 2023 两会建议:仿生
- 下一篇: 编写程序判断两个数组是否相等,然后编写一
