2014年12月23日 星期二

java程式設計題目---字母轉換【數字轉字母】

設計一程式,提示使用者輸入正整數n,印出第n個小寫英文字母。
例如:輸入1,印出a
  1. import java.util.Scanner;
  2.  
  3. public class C1
  4. {
  5. public static void main(String[] args)
  6. {
  7. Scanner input = new Scanner(System.in);
  8. System.out.println("please enter a number:");
  9. int a = input.nextInt();
  10. int b = a + 96;
  11. System.out.println("The answer of the question is:" + (char)b);
  12. }
  13.  
  14. }

沒有留言:

張貼留言

Go(Golang)程式語言 設定GCC

下載MSYS2:  https://www.msys2.org/ 安裝 程式開始執行後輸入: pacman -Syu y y 在安裝目錄底下找到msys2.exe,雙擊執行 輸入指令: pacman -Su pacman -S --needed base-devel mingw-...