返回列表 發帖

我的第一支程式

在螢幕上顯示 hello 字樣.
  1. #include<iostream>     //引入 <基本輸入輸出> 標頭檔 input & output stream
  2. #include<cstdlib>      //引入 <標準函式庫> 標頭檔 c standard library
  3. using namespace std;   //指定命名空間為 std
  4. int main()    //主函式
  5. {
  6.     //你要做的事
  7.     cout<<"hello"<<endl;   //cout輸出  endl換行
  8.     system("pause");       //讓畫面暫停
  9.     return 0;              //回傳0到主控台,告知該程式已成功執行
  10. }
複製代碼
//        ()小括號
//        []中括號
//        {}大括號

本帖最後由 鄭繼威 於 2022-11-11 20:23 編輯
  1. #include<iostream>        //引入輸入輸出串流函式庫
  2. #include<cstdlib>        //C standard 函式庫
  3. using namespace std;        //指定命名空間為std

  4. //主函式
  5. int main()
  6. {
  7.         //輸出 <<串接符號 (當方法、變數、字串要一起使用的時候)
  8.         //        "雙引號(字串)"
  9.         //endl 換行
  10.         cout<<"你好";
  11.         cout<<"hi";
  12.        
  13.         system("pause");        //讓黑色畫面暫停
  14.     return 0;  // 告知程式已執行完成
  15. }
複製代碼

TOP

返回列表