计算机代码如何求三角形面积,简单的程序来计算三角形的面积

我让程序正常工作。几乎。我不知道在程序终止时如何保持屏幕显示状态,因此结果从不可见,但是至少可以运行该程序并输入前两个数字:

IDENTIFICATION DIVISION.

PROGRAM-ID. TRIANG.

DATA DIVISION.

WORKING-STORAGE SECTION.

77 BASE PIC 9(04) VALUE ZEROS.

77 ALTURA PIC 9(04) VALUE ZEROS.

77 HAREA PIC 9(06) VALUE ZEROS.

77 DUMMY PIC 9(01) VALUE ZEROS.

SCREEN SECTION.

01 TELA.

02 BLANK SCREEN.

02 LINE 04 COLUMN 21 VALUE

\"CALCULO DA AREA DE UM TRIANGULO\".

02 LINE 06 COLUMN 15 VALUE

\"AUTOR: Alexandre\".

02 LINE 10 COLUMN 21 VALUE \"ENTRE COM O VALOR DA ALTURA...\".

02 LINE 12 COLUMN 21 VALUE \"ENTRE COM O VALOR DA BASE...\".

02 LINE 14 COLUMN 21 VALUE \"ENTRE COM O VALOR DA AREA...\".

PROCEDURE DIVISION.

INICIO.

DISPLAY TELA.

DADOS.

ACCEPT ALTURA AT LINE 10 COLUMN 51.

ACCEPT BASE AT LINE 12 COLUMN 51.

CALCULO.

MULTIPLY BASE BY ALTURA GIVING HAREA.

DIVIDE 2 INTO HAREA.

FIM.

DISPLAY HAREA LINE 14 COLUMN 51.

DISPLAY \"FIM DE PROGRAMA\" LINE 24 COLUMN 31.

ACCEPT DUMMY AT LINE 1 COLUMN 1.

STOP RUN.

更好的版本:

IDENTIFICATION DIVISION.

PROGRAM-ID. TRIANG.

DATA DIVISION.

WORKING-STORAGE SECTION.

77 BASE PIC 9(04) VALUE ZEROS.

77 ALTURA PIC 9(04) VALUE ZEROS.

77 HAREA PIC 9(07) VALUE ZEROS.

77 AGAIN PIC X VALUE \'N\'.

SCREEN SECTION.

01 TELA.

02 BLANK SCREEN.

02 LINE 04 COLUMN 21 VALUE

\"CALCULO DA AREA DE UM TRIANGULO\".

02 LINE 06 COLUMN 15 VALUE

\"AUTOR: Alexandre\".

02 LINE 10 COLUMN 21 VALUE \"ENTRE COM O VALOR DA ALTURA [____]\".

02 LINE 10 COLUMN 50 PIC ZZZ9 Using ALTURA.

02 LINE 12 COLUMN 21 VALUE \"ENTRE COM O VALOR DA BASE...[____]\".

02 LINE 12 COLUMN 50 PIC ZZZ9 Using BASE.

02 LINE 14 COLUMN 21 VALUE \" VALOR DA AREA..\".

02 LINE 14 COLUMN 48 PIC ZZZZZZ9 From HAREA.

02 LINE 16 COLUMN 21 VALUE \" FINIS...[N]\".

02 LINE 16 COLUMN 50 PIC X Using AGAIN.

PROCEDURE DIVISION.

INICIO.

DISPLAY TELA.

PERFORM SCREENS UNTIL AGAIN = \'Y\'

STOP RUN.

SCREENS.

ACCEPT TELA.

MULTIPLY BASE BY ALTURA GIVING HAREA.

DIVIDE 2 INTO HAREA.

DISPLAY TELA.

  • 0
    点赞
  • 0
    收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
©️2022 CSDN 皮肤主题:数字20 设计师:CSDN官方博客 返回首页
评论
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值