java
2023-05-07
標準輸出
public class App {
public static void main(String[] args) {
System.out.println("Hello, World!");
System.out.print("Hello, ");
System.out.print("Aaron!");
System.out.printf("My name is %s", "Aaron");
}
aaronlife changed 3 months agoView mode Like Bookmark
猜數字遊戲
使用者輸入1~3之間的數字,如果使用者猜對,則顯示YES,猜錯顯示NO
參考程式碼
import random
pc = random.randint(1, 3) # 電腦的答案
player = int(input("請輸入1~3之間的數字:")) # 讓玩家猜一個數字
if pc == player:
aaronlife changed 3 months agoView mode Like Bookmark