stl字符串去除空格_在列表中推送字符并在C ++ STL中将它们打印为空格
生活随笔
收集整理的這篇文章主要介紹了
stl字符串去除空格_在列表中推送字符并在C ++ STL中将它们打印为空格
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
stl字符串去除空格
In this example, we are declaring a character list and pushing the characters from 'A' to 'Z' using a for loop and push_back() function then printing the value of the vector separated by space.
在此示例中,我們聲明了一個字符列表,并使用for循環和push_back()函數 將字符從'A' 推 送到'Z' ,然后打印以空格分隔的向量的值 。
Code:
碼:
#include <iostream> #include <list> //for list using namespace std;int main() {// list of character elementslist<char> clist;// append characters from 'A' to 'Z'for (char i = 'A'; i <= 'Z'; ++i) {clist.push_back(i);}// printing all elementscout << "list (clist) elements: " << endl;for (char x : clist)cout << x << ' ';cout << endl;return 0; }Output
輸出量
list (clist) elements: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z翻譯自: https://www.includehelp.com/stl/push-characters-in-a-list-and-print-them-separated-by-space-in-cpp-stl.aspx
stl字符串去除空格
總結
以上是生活随笔為你收集整理的stl字符串去除空格_在列表中推送字符并在C ++ STL中将它们打印为空格的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: MySQL文件后_MySQL误删除文件后
- 下一篇: cad中tk什么意思_设计中的“Neob