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

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                為了練習使用do..while和while,特地使用此實例,一個簡單的猜數游戲對while循環進行的練習使用。所有的東西都在注釋當中: ~~~ #include <stdio.h> #include <conio.h> /****************** * 該實例用于實現一個簡單的猜數字的游戲 * 主要用于練習使用while循環 * 開始的時候需要用戶輸入游戲密碼(1234) * 如果用戶輸入錯誤 * 則提示用戶重新輸入 * 如果三次輸入錯誤,則提示用戶退出程序 *******************/ int main(void) { int passwd = 0,Number = 0,price = 58,i = 0; printf("\n====This is a Number Guess Game!====\n"); //提示信息 while(passwd != 1234){ if(i >= 3) /*如果輸入錯誤次數大于3就退出*/ { printf("\n Please input the right password!\n"); return; } i++; puts("Please input Password: "); scanf("%d",&passwd); /*要求輸入密碼*/ } i = 0; while(Number != price){ do{ puts("Please input a number between 1 and 100: "); scanf("%d",&Number); printf("Your input number is %d\n",Number); }while(!(Number >= 1 && Number <= 100)); if(Number >= 90) /*輸入大于90的情況*/ { printf("Too Bigger!Press any key to try again!\n"); }else if(Number >= 70 && Number <= 90) /*比較大的情況*/ { printf("Bigger!\n"); }else if(Number >= 1 && Number <= 30) /*太小的情況*/ { printf("Too Small!Press any key to try again!\n"); }else if(Number > 30 && Number <= 50) /*比較小的情況*/ { printf("Small!! Press any key to try again!\n"); }else{ if(Number == price) { printf("OK! You are right!Bye Bye!\n"); }else if(Number < price){ printf("Sorry,Only a little smaller!Press any key to try again!\n"); }else if(Number > price) printf("Sorry,Only a little bigger!Press any key to try again!\n"); } getch(); } /*************************** * 1:一個比較經典的面試題目 * do,while和while的區別 * 根據學習,可以知道do..while能夠保證至少有一次運行。 * 2:常見的循環的應用 * 1).計數循環 * 2).輸入驗證循環 * 3).哨兵循環。循環程序不斷的檢查,讀和處理數據 * 4).延時循環。循環中不實現任何功能,只是使CPU * 等待一定時間后再繼續執行,在單片機程序中比較常用 * 5).查找循環。按給定的對象進行查找 * 6).無限循環,不停的執行。在危險信號的檢測中經常用到 **************************/ return 0; } ~~~ 我的程序的輸出結果: ![這里寫圖片描述](https://box.kancloud.cn/2016-05-24_5743c0746e82a.jpg "") 密碼是1234奧!!
                  <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>

                              哎呀哎呀视频在线观看