#27353: 解答 ( 含註解 )


los2516lir@gmail.com (Youuin Wang)


/*

學習所有程式語言的第一個練習題 

請寫一個程式,可以讀入指定的字串,並且輸出指定的字串。

 

比如:輸入字串 "world", 則請輸出 "hello, world"

*/

 

#include<iostream> //引入 iostream.h 之標頭檔

using namespace std; // 引入 iostream.h 標頭檔之 std 命名空間

 

int main(void){ //執行程式

    string word; //建立名為 word 的字串變數,不設初始值

    while( cin >> word ){ //將鍵盤輸入的值賦值到 word 字串,之後執行迴圈

        cout <<  "hello, " << word; //將"hello, "字串和 word 之值串聯輸出至螢幕

    }

}

#27357: Re:解答 ( 含註解 )


los2516lir@gmail.com (Youuin Wang)


這裡能請求刪除嗎?

我沒注意到不能po答案,是我的錯

我很抱歉