返回列表 發帖

while 迴圈 (一)

利用while迴圈, 垂直列出 1~20.
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int i=1;  //初始值
  7.     while(i<=20)    //持續運作的條件
  8.     {
  9.         cout<<i<<endl;
  10.         i++;   
  11.     }
  12.     system("pause");
  13.     return 0;   
  14. }
複製代碼

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main ()
  5. {
  6.     int i=1;
  7.     while(i<=20)
  8.     {
  9.         cout<<i<<endl;
  10.         i++;
  11.     }
  12.     system("pause");
  13.     return 0;
  14. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int i=0;
  7.     while(i<=20)
  8.     {
  9.         cout<<i<<endl;
  10.         i++;      
  11.     }  
  12.     system("pause");
  13.     return 0;
  14. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {   
  6.     int i=1;
  7.     while(i<=20)
  8.     {
  9.         cout<<i<<endl;
  10.         i++;
  11.     }
  12.     system("pause");
  13.     return 0;   
  14. }
複製代碼
hahahahahahahaha

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int i=1;
  7.     while(i<=20)
  8.     {
  9.         cout<<i<<endl;
  10.         i++;            
  11.     }
  12.     system("pause");
  13.     return 0;
  14. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int i=1;  
  7.     while(i<=20)   
  8.     {
  9.         cout<<i<<endl;
  10.         i++;   
  11.     }
  12.     system("pause");
  13.     return 0;   
  14. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int i=1;  
  7.     while(i<=200000)   
  8.     {
  9.         cout<<i<<endl;
  10.         i++;   
  11.     }
  12.     system("pause");
  13.     return 0;   
  14. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.    int a=1;   
  7.     while(a<=20)   
  8.     {
  9.         cout<<a<<endl;
  10.         a++;   
  11.     }
  12.     system("pause");
  13.     return 0;
  14. }
複製代碼
李宇澤Oscar

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int i=1;   
  7.     while(i<=20)     
  8.     {
  9.         cout<<i<<endl;
  10.         i++;   
  11.     }
  12.     system("pause");
  13.     return 0;   
  14. }
複製代碼

TOP

本帖最後由 陳宥穎 於 2019-10-25 19:23 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int i=1;  //初始值
  7.     while(i<=20)    //持續運作的條件
  8.     {
  9.         cout<<i<<endl;
  10.         i++;   
  11.     }
  12.     system("pause");
  13.     return 0;   
  14. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int i=1;
  7.     while(i<=20)   
  8.     {
  9.         cout<<i<<endl;
  10.         i++;   
  11.     }
  12.     system("pause");
  13.     return 0;   
  14. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int i=1;   
  7.     while(i<=20)     
  8.     {
  9.         cout<<i<<endl;
  10.         i++;   
  11.     }
  12.     system("pause");
  13.     return 0;   
  14. }
複製代碼
Huang chenhao

TOP

返回列表