<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # C++ 程序:使用結構存儲和顯示信息 > 原文: [https://www.programiz.com/cpp-programming/examples/information-structure-array](https://www.programiz.com/cpp-programming/examples/information-structure-array) #### 該程序使用結構存儲 10 名學生的信息(姓名,名次和分數)。 要理解此示例,您應該了解以下 [C++ 編程](/cpp-programming "C++ tutorial")主題: * [C++ 數組](/cpp-programming/arrays) * [C++ 結構](/cpp-programming/structure) * * * 在該程序中,創建了一個結構`student`。 該結構具有三個成員:`name`(字符串),`roll`(整數)和`marks`(浮點)。 然后,我們創建了一個大小為 10 的結構數組,以存儲 10 個學生的信息。 通過 [C++ `for`循環](/cpp-programming/for-loop "C++ for loop"),程序將從用戶那里獲取 10 名學生的信息,并將其顯示在屏幕上。 * * * ## 示例:將信息存儲在結構中并顯示 ```cpp #include <iostream> using namespace std; struct student { char name[50]; int roll; float marks; } s[10]; int main() { cout << "Enter information of students: " << endl; // storing information for(int i = 0; i < 10; ++i) { s[i].roll = i+1; cout << "For roll number" << s[i].roll << "," << endl; cout << "Enter name: "; cin >> s[i].name; cout << "Enter marks: "; cin >> s[i].marks; cout << endl; } cout << "Displaying Information: " << endl; // Displaying information for(int i = 0; i < 10; ++i) { cout << "\nRoll number: " << i+1 << endl; cout << "Name: " << s[i].name << endl; cout << "Marks: " << s[i].marks << endl; } return 0; } ``` **輸出** ```cpp Enter information of students: For roll number1, Enter name: Tom Enter marks: 98 For roll number2, Enter name: Jerry Enter marks: 89 . . . Displaying Information: Roll number: 1 Name: Tom Marks: 98 . . . ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看