Search this site
Embedded Files
程式設計解題
  • 新手村
  • python解題學習地圖
  • ZeroJudge 說明
  • 線上解題網站
  • 網路資源
  • 封
    • playground
      • pygame 教程
    • snakify.org
      • Lesson 1 KeyPoints
      • Lesson 2 KeyPoints
      • Lesson 3. KeyPoins
      • Lesson 4 KeyPoints
      • Lesson 5 KeyPoints
    • Think Python: How to Think Like a Computer Scientist. by Allen B. Downey
    • Invent Your Own Computer Games with Python, 4th Edition
    • Make Games using Python
程式設計解題

ZeroJudge 高中生程式解題系統

ZeroJudge 高中生程式解題系統

在zerojudge的網頁上已經有提示各程式語言解題基本架構,但以下補充較為常用的讀取input的基本框架。

解題 Pyhon 輸入讀取 基本框架

假設 有 times 筆資料要讀取,每筆資料有一行,內有兩筆數字是以空白隔開,請輸出兩數的差。

import sysfor times in sys.stdin:#有 times 筆資料要讀取 for i in range(int(times)): aline = sys.stdin.readline()#讀一行 a,b = map(int,aline.strip().split())#strip()消去換行符號, split()依空白分割成list, map()把list 內容依照位置存進等號左邊的變數們。 print(str(a-b))#本例子印出兩數之差

執行結果

APCS

部分可能解答

https://sites.google.com/site/zsgititit/zi-xun-neng-li-jian-ding

dailin@慧燈中學© 程式設計
Report abuse
Report abuse