久久久久久久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'>

                            主站蜘蛛池模板: 特黄视频 | 成人国产在线视频 | 国产精品久久久久久久午夜片 | 美女爽到呻吟久久久久 | 国产 日韩 欧美 中文 在线播放 | 中文字幕国产高清 | 亚洲免费观看视频 | 久久亚洲免费 | 浴室洗澡偷拍一区二区 | 中文字幕亚洲一区二区va在线 | 色影视| 亚洲精品福利视频 | 久久免费视频1 | 亚洲精选久久 | 色爱综合网 | 谁有毛片 | 欧美精品在线一区二区三区 | 国产成在线观看免费视频 | 99精品免费在线观看 | 欧产日产国产精品视频 | 国产片一区二区三区 | 亚洲国产成人av好男人在线观看 | 免费观看黄网站 | 国产精品99久久久久久宅男 | 亚洲国产一区在线 | 欧美在线视频免费 | 在线欧美视频 | 国产伦精品一区二区三区高清 | 亚洲另类春色偷拍在线观看 | 在线天堂免费中文字幕视频 | 国产美女在线观看 | 国产成人精品一区二区三区在线 | 欧美日韩在线观看一区 | 成人免费视频网址 | 国产精品久久久久久亚洲调教 | 美女一级a毛片免费观看97 | 欧美在线观看免费观看视频 | 色偷偷人人澡人人爽人人模 | 正在播放一区二区 | 色约约视频 | 国产一区二区三区四区三区四 |