求一個包括輸入語句、輸出語句、賦值語句、條件語句、循環語句的簡
//---------------------------------------------------------------------------
#include
#include
int main(int argc, char* argv[])
{
char s[80];
int i;
gets(s);
for (i=strlen(s)-1; i>=0; i--) printf("%c",s[i]);
return 0;
}
//---------------------------------------------------------------------------
java中的輸入語句是怎樣的呢
找了很多的資料終于被我找到了點頭緒了。
。 哈哈 。
。好高興。
。
看看這個的輸入 。 public static void main(String[] args) throws IOException{ InputStreamReader reader = new InputStreamReader(System。
in); BufferedReader input = new BufferedReader(reader); System。out。
print("Enter the number: "); String text = input。readLine(); } 這段代碼實在太長了。
我想簡化點。 能不能不要那個throws IOException 把那個去掉。
。結果是程序無法編譯的結果。
后來又想。
在網上尋找別的更簡便的輸入方法。
。 編輯特別推薦: 指點一下:到底該不該去考JAVA認證? Java認證權威問答精華集 終于看到了 Java5。
0以后可以使用java。util。
Scanner類: Scanner sc = new Scanner(System。in); int i = sc。
nextInt(); long l = sc。nextLong(); float f = sc。
nextFloat(); double d = sc。nextDouble(); String s = sc。
nextLine(); 這個多簡單啊。
。 來得實在。
。
這樣就簡單多了。