題目:a001-哈囉

內容學習所有程式語言的第一個練習題 ,請寫一個程式,

             可以讀入指定的字串,並且輸出指定的字串。

輸入說明輸入指定的文字

輸出說明輸出指定的文字

範例輸入

world
C++
mary

範例輸出:

hello, world
hello, C++
hello, mary

 

解題:

 

import java.util.Scanner;

 

public class java{
        public static void main(String[] args){

                  Scanner word = new Scanner(System.in);
                  String s;
                  while(word.hasNext()){

                         s = word.nextLine();

                         System.out.println("hello, " + s);

 

                   }

       }

}

 

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 a5u83x06777 的頭像
    a5u83x06777

    莫忘初衷

    a5u83x06777 發表在 痞客邦 留言(0) 人氣()