久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<i id='32Ku7'><tr id='32Ku7'><dt id='32Ku7'><q id='32Ku7'><span id='32Ku7'><b id='32Ku7'><form id='32Ku7'><ins id='32Ku7'></ins><ul id='32Ku7'></ul><sub id='32Ku7'></sub></form><legend id='32Ku7'></legend><bdo id='32Ku7'><pre id='32Ku7'><center id='32Ku7'></center></pre></bdo></b><th id='32Ku7'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='32Ku7'><tfoot id='32Ku7'></tfoot><dl id='32Ku7'><fieldset id='32Ku7'></fieldset></dl></div>
    • <bdo id='32Ku7'></bdo><ul id='32Ku7'></ul>
    <legend id='32Ku7'><style id='32Ku7'><dir id='32Ku7'><q id='32Ku7'></q></dir></style></legend>

    <small id='32Ku7'></small><noframes id='32Ku7'>

        <tfoot id='32Ku7'></tfoot>

        在 C++ 中讀取格式化輸入的最簡單方法?

        The easiest way to read formatted input in C++?(在 C++ 中讀取格式化輸入的最簡單方法?)
          <bdo id='PpxnD'></bdo><ul id='PpxnD'></ul>
            <i id='PpxnD'><tr id='PpxnD'><dt id='PpxnD'><q id='PpxnD'><span id='PpxnD'><b id='PpxnD'><form id='PpxnD'><ins id='PpxnD'></ins><ul id='PpxnD'></ul><sub id='PpxnD'></sub></form><legend id='PpxnD'></legend><bdo id='PpxnD'><pre id='PpxnD'><center id='PpxnD'></center></pre></bdo></b><th id='PpxnD'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='PpxnD'><tfoot id='PpxnD'></tfoot><dl id='PpxnD'><fieldset id='PpxnD'></fieldset></dl></div>

            <legend id='PpxnD'><style id='PpxnD'><dir id='PpxnD'><q id='PpxnD'></q></dir></style></legend>
          • <small id='PpxnD'></small><noframes id='PpxnD'>

            <tfoot id='PpxnD'></tfoot>
                <tbody id='PpxnD'></tbody>

                1. 本文介紹了在 C++ 中讀取格式化輸入的最簡單方法?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  有沒有辦法讀取這樣的格式化字符串,例如:48754+7812=Abcs.

                  Is there any way to read a formatted string like this, for example :48754+7812=Abcs.

                  假設我有三個字符串 X、Y 和 Z,我想要

                  Let's say I have three stringz X,Y and Z, and I want

                  X = 48754 
                  Y = 7812
                  Z = Abcs
                  

                  兩個數字的大小和字符串的長度可能會有所不同,所以我不想使用 substring() 或類似的東西.

                  The size of the two numbers and the length of the string may vary, so I dont want to use substring() or anything like that.

                  是否可以給C++這樣的參數

                  Is it possible to give C++ a parameter like this

                  ":#####..+####..=SSS.."
                  

                  所以它直接知道發生了什么?

                  so it knows directly what's going on?

                  推薦答案

                  一種可能性是 boost::split(),它允許指定多個分隔符并且不需要輸入大小的先驗知識:

                  A possibility is boost::split(), which allows the specification of multiple delimiters and does not require prior knowledge of the size of the input:

                  #include <iostream>
                  #include <vector>
                  #include <string>
                  
                  #include <boost/algorithm/string.hpp>
                  #include <boost/algorithm/string/split.hpp>
                  
                  int main()
                  {
                      std::vector<std::string> tokens;
                      std::string s(":48754+7812=Abcs");
                      boost::split(tokens, s, boost::is_any_of(":+="));
                  
                      // "48754" == tokens[0]
                      // "7812"  == tokens[1]
                      // "Abcs"  == tokens[2]
                  
                      return 0;
                  }
                  

                  或者,使用sscanf():

                  #include <iostream>
                  #include <cstdio>
                  
                  int main()
                  {
                      const char* s = ":48754+7812=Abcs";
                      int X, Y;
                      char Z[100];
                  
                      if (3 == std::sscanf(s, ":%d+%d=%99s", &X, &Y, Z))
                      {
                          std::cout << "X=" << X << "
                  ";
                          std::cout << "Y=" << Y << "
                  ";
                          std::cout << "Z=" << Z << "
                  ";
                      }
                  
                      return 0;
                  }
                  

                  然而,這里的限制是字符串的最大長度 (Z) 必須在解析輸入之前確定.

                  However, the limitiation here is that the maximum length of the string (Z) must be decided before parsing the input.

                  這篇關于在 C++ 中讀取格式化輸入的最簡單方法?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  read input files, fastest way possible?(讀取輸入文件,最快的方法?)
                  Reading from .txt file into two dimensional array in c++(從 .txt 文件讀取到 C++ 中的二維數組)
                  How to simulate a key press in C++(如何在 C++ 中模擬按鍵按下)
                  Why doesn#39;t getline(cin, var) after cin.ignore() read the first character of the string?(為什么在 cin.ignore() 之后沒有 getline(cin, var) 讀取字符串的第一個字符?)
                  What is the cin analougus of scanf formatted input?(scanf 格式輸入的 cin 類比是什么?)
                  Issue with cin when spaces are inputted, using string class(使用字符串類輸入空格時出現 cin 問題)
                  <legend id='3T9Us'><style id='3T9Us'><dir id='3T9Us'><q id='3T9Us'></q></dir></style></legend>
                2. <tfoot id='3T9Us'></tfoot>

                    <i id='3T9Us'><tr id='3T9Us'><dt id='3T9Us'><q id='3T9Us'><span id='3T9Us'><b id='3T9Us'><form id='3T9Us'><ins id='3T9Us'></ins><ul id='3T9Us'></ul><sub id='3T9Us'></sub></form><legend id='3T9Us'></legend><bdo id='3T9Us'><pre id='3T9Us'><center id='3T9Us'></center></pre></bdo></b><th id='3T9Us'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='3T9Us'><tfoot id='3T9Us'></tfoot><dl id='3T9Us'><fieldset id='3T9Us'></fieldset></dl></div>

                        <bdo id='3T9Us'></bdo><ul id='3T9Us'></ul>

                          <tbody id='3T9Us'></tbody>
                        1. <small id='3T9Us'></small><noframes id='3T9Us'>

                            主站蜘蛛池模板: 中文有码在线 | 欧美又大又硬又粗bbbbb | 91综合在线 | 青青草福利视频 | аⅴ资源新版在线天堂 | 中文字幕www | 欧美成人一区二区三区片免费 | 激情久久久 | 国产网站视频 | 婷婷色综合| h视频在线播放 | 亚洲免费一区二区 | 欧美在线小视频 | 午夜视频福利 | 久久精品亚洲 | 午夜在线 | 青草视频网站 | 日韩黄色大片 | 亚洲一区二区在线视频 | 亚洲精品伦理 | 中文字幕永久免费 | 国产日韩在线播放 | 91av在线播放 | 午夜网站在线观看 | 国产亚洲视频在线观看 | 真实人妻互换毛片视频 | 欧美精品一区二区三区四区 | 欧美精品久久久久久久 | 18在线观看免费入口 | 丰满少妇在线观看网站 | 亚洲福利在线观看 | 欧美日韩中文字幕在线 | 久草资源在线观看 | 性生活毛片| 毛片91 | 欧美三级成人 | 久操久操 | 欧美日韩成人 | 国产激情在线视频 | av不卡一区 | 黄色小视频免费看 |