伪代码输入,处理,输出

时间:2014-03-16 15:44:04

标签: pseudocode

  

您需要设计一个应用程序,提示用户输入1到12之间的数字。获取输入后,显示具有相应月份的数字。 (例如:这是第1个月...... 1月,这是第2个月...... 2月,这是第12个月...... 12月)。您可以使用正确的答案填写此文档。

这是我到目前为止所做的,但我不知道在处理部分或输出中放入什么。

  

伪代码:这是您编写确切指令以编写IPO图表的处理部分以及生成输出所需执行的操作的地方。

Input number of month

IF MONTH = 1 THEN
    DISPLAY “January”
END IF

IF MONTH = 2 THEN
    DISPLAY “February”
END IF

IF MONTH = 3 THEN
    DISPLAY “March”
END IF

IF MONTH = 4 THEN
    DISPLAY “April”
END IF

IF MONTH = 5 THEN
    DISPLAY “May”
END IF

IF MONTH = 6 THEN
    DISPLAY “June”
END IF

IF MONTH = 7 THEN
    DISPLAY “July”
END IF

IF MONTH = 8 THEN
    DISPLAY “August”
END IF

IF MONTH = 9 THEN
    DISPLAY “September”
END IF

IF MONTH = 10 THEN
    DISPLAY “October”
END IF

IF MONTH = 11 THEN
    DISPLAY “November”
END IF

IF MONTH = 12 THEN
    DISPLAY “December”
END IF

End

Processing

Output

2 个答案:

答案 0 :(得分:0)

我会这样做:

  

变量:MONTH_NUMBER,MONTH_NAME

     

输入:

   READ(MONTH_NUMBER)
     

处理:

   IF  MONTH_NUMBER = 1  THEN:
        MONTH_NAME = "January"
         .
         .
         .
   IF  MONTH_NUMBER = 12  THEN:
        MONTH_NAME = "December"
     

输出:

   PRINT(MONTH_NAME)

答案 1 :(得分:0)

1) Prompt Month_num
2) GET Month_num
3) Set Msg = ‘null’
4) Month_name
  IF (month_num ==1) then
  Month_name = ‘Jan’
    ELSE
      IF (month_num ==2) then
      Msg = ‘Feb’
    ELSE
      IF (month_num ==3) then
      Msg = ‘Mar’
    ELSE
      IF (month_num ==4) then
      Msg = ‘Apr’
    ELSE
      IF (month_num ==5) then
      Msg = ‘May’
    ELSE
      IF (month_num ==6) then
      Msg = ‘June’
    ELSE
      IF (month_num ==7) then
      Msg = ‘July’
    ELSE
      IF (month_num ==8) then
      Msg = ‘Aug’
    ELSE
      IF (month_num ==9) then
      Msg = ‘Sept’
      ELSE
      IF (month_num ==10) then
      Msg = ‘Oct’
    ELSE
      IF (month_num ==11) then
      Msg = ‘Nov’
    ELSE
      IF (month_num =12) then
      Msg = ‘Dec’
    ELSE
      MSG = “Invalid entry”
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
END.

CASEOF Month_num
'1' : Print 'Jan'
'2' : Print 'Feb'
so on so forth
other : Print 'invalid month'
ENDCASE
END.