跳轉到內容

程式設計基礎/輸入-處理-輸出模型

來自華夏公益教科書,開放的書籍,為開放的世界

輸入-處理-輸出 (IPO) 模型是系統分析和軟體工程中廣泛使用的一種方法,用於描述資訊處理程式或其他過程的結構。IPO 模型是描述過程的最基本結構。[1]

使用輸入-處理-輸出模型的計算機程式或任何其他型別的過程都會從使用者或其他來源接收輸入,對輸入進行一些計算,然後返回計算結果。該系統將工作分為三個類別:[2]

  • 來自環境的要求(輸入)
  • 基於要求的計算(處理)
  • 環境的規定(輸出)

例如,可以編寫一個程式將華氏溫度轉換為攝氏溫度。按照 IPO 模型,該程式必須

  • 詢問使用者華氏溫度(輸入)
  • 執行計算以將華氏溫度轉換為相應的攝氏溫度(處理)
  • 顯示攝氏溫度(輸出)

虛擬碼

[編輯 | 編輯原始碼]
Function Main
    ... This program converts an input Fahrenheit temperature to Celsius.

    Declare Real fahrenheit
    Declare Real celsius
    
    Output "Enter Fahrenheit temperature:"
    Input fahrenheit

    Assign celsius = (fahrenheit - 32) * 5 / 9

    Output fahrenheit & "° Fahrenheit is " & celsius & "° Celsius"
End
Enter Fahrenheit temperature:
100
100° Fahrenheit is 37.7777777777778° Celsius

流程圖

[編輯 | 編輯原始碼]

Fahrenheit to Celsius flowchart

參考資料

[編輯 | 編輯原始碼]
華夏公益教科書