• <bdo id='X6zvj'></bdo><ul id='X6zvj'></ul>

    1. <small id='X6zvj'></small><noframes id='X6zvj'>

      1. <tfoot id='X6zvj'></tfoot>
      2. <legend id='X6zvj'><style id='X6zvj'><dir id='X6zvj'><q id='X6zvj'></q></dir></style></legend>
        <i id='X6zvj'><tr id='X6zvj'><dt id='X6zvj'><q id='X6zvj'><span id='X6zvj'><b id='X6zvj'><form id='X6zvj'><ins id='X6zvj'></ins><ul id='X6zvj'></ul><sub id='X6zvj'></sub></form><legend id='X6zvj'></legend><bdo id='X6zvj'><pre id='X6zvj'><center id='X6zvj'></center></pre></bdo></b><th id='X6zvj'></th></span></q></dt></tr></i><div id='X6zvj'><tfoot id='X6zvj'></tfoot><dl id='X6zvj'><fieldset id='X6zvj'></fieldset></dl></div>

      3. 一根线上有多个输入

        时间:2023-10-08
            <tbody id='LzmPS'></tbody>

          <small id='LzmPS'></small><noframes id='LzmPS'>

          <legend id='LzmPS'><style id='LzmPS'><dir id='LzmPS'><q id='LzmPS'></q></dir></style></legend>
        1. <i id='LzmPS'><tr id='LzmPS'><dt id='LzmPS'><q id='LzmPS'><span id='LzmPS'><b id='LzmPS'><form id='LzmPS'><ins id='LzmPS'></ins><ul id='LzmPS'></ul><sub id='LzmPS'></sub></form><legend id='LzmPS'></legend><bdo id='LzmPS'><pre id='LzmPS'><center id='LzmPS'></center></pre></bdo></b><th id='LzmPS'></th></span></q></dt></tr></i><div id='LzmPS'><tfoot id='LzmPS'></tfoot><dl id='LzmPS'><fieldset id='LzmPS'></fieldset></dl></div>
          <tfoot id='LzmPS'></tfoot>

              <bdo id='LzmPS'></bdo><ul id='LzmPS'></ul>
                  本文介绍了一根线上有多个输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我看了也没有用,我怕是这么简单的问题,没人敢问.

                  I have looked to no avail, and I'm afraid that it might be such a simple question that nobody dares ask it.

                  一个人可以在一行中从标准输入中输入多个内容吗?我的意思是:

                  Can one input multiple things from standard input in one line? I mean this:

                  float a, b;
                  char c;
                  
                  // It is safe to assume a, b, c will be in float, float, char form?
                  cin >> a >> b >> c;
                  

                  推荐答案

                  是的,您可以完全使用您描述的语法从 cin 输入多个项目.结果基本上等同于:

                  Yes, you can input multiple items from cin, using exactly the syntax you describe. The result is essentially identical to:

                  cin >> a;
                  cin >> b;
                  cin >> c;
                  

                  这是由于一种称为运算符链接"的技术.

                  This is due to a technique called "operator chaining".

                  每次调用 operator>>(istream&, T)(其中 T 是某种任意类型)都会返回对其第一个参数的引用.所以 cin >>a 返回 cin,它可以用作 (cin>>a)>>b 等等.

                  Each call to operator>>(istream&, T) (where T is some arbitrary type) returns a reference to its first argument. So cin >> a returns cin, which can be used as (cin>>a)>>b and so forth.

                  注意,每次调用 operator>>(istream&, T) 首先消耗所有空白字符,然后是满足输入操作所需的尽可能多的字符,最多(但不包括)) 下一个空白字符、无效字符或 EOF.

                  Note that each call to operator>>(istream&, T) first consumes all whitespace characters, then as many characters as is required to satisfy the input operation, up to (but not including) the first next whitespace character, invalid character, or EOF.

                  这篇关于一根线上有多个输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何在 C++ 中逐行读取文件中的整数组 下一篇:使用字符串类输入空格时出现 cin 问题

                  相关文章

                  最新文章

                    <legend id='njpoo'><style id='njpoo'><dir id='njpoo'><q id='njpoo'></q></dir></style></legend>

                      <i id='njpoo'><tr id='njpoo'><dt id='njpoo'><q id='njpoo'><span id='njpoo'><b id='njpoo'><form id='njpoo'><ins id='njpoo'></ins><ul id='njpoo'></ul><sub id='njpoo'></sub></form><legend id='njpoo'></legend><bdo id='njpoo'><pre id='njpoo'><center id='njpoo'></center></pre></bdo></b><th id='njpoo'></th></span></q></dt></tr></i><div id='njpoo'><tfoot id='njpoo'></tfoot><dl id='njpoo'><fieldset id='njpoo'></fieldset></dl></div>
                    1. <small id='njpoo'></small><noframes id='njpoo'>

                      <tfoot id='njpoo'></tfoot>
                      • <bdo id='njpoo'></bdo><ul id='njpoo'></ul>