帕斯卡问题 [英] Pascal question

查看:84
本文介绍了帕斯卡问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这段代码中,我可以在一行中输入数字和运算,例如 22 + 3/5 = :confused:
我想介绍一下目的和结论:rolleyes:

In this code can I make the number and operation in one line such as 22+3/5=:confused:
and I want introduction, Purpose and conclusion :rolleyes:

program calculator_in_pascal;
var
   x : integer;
   num1 , num2 , ms , amo : real;
   ope , ord : char;
   cho : string;
begin
   num1 := 0;
   x := 0;

                  { calculator program }
   writeln();
   writeln('' ______________________________________________________'');
   writeln(''| After each Number or Operation, Please press <Enter> |'');
   writeln(''|______________________________________________________|'');
   Readln(num1);
   while x < 1 do
   begin
   Readln(ope);
   if ope = ''+'' then
   begin
      readln(num2);
      num1 := num1 + num2;
   end         {addition}
   else if ope = ''-'' then
   begin
      readln(num2);
      num1 := num1 - num2;
   end         {Subtraction}
   else if ope = ''*'' then
   begin
      readln(num2);
      num1 := num1 * num2;
   end         {Multiplication}
   else if ope = ''/'' then
   begin
      readln(num2);
      num1 := num1 / num2;
   end        {division}
   else if ope = ''='' then
   begin
      writeln(num1:0:9);
      writeln();
      writeln(''select 1- for Continue OR 2- for Exit'');
      readln(ord);
      if ord = ''1'' then
          begin
          continue;
          end
      else if ord = ''2'' then
          begin
          break;
          end;
   end;
   end;

   writeln();
   writeln();
   writeln(''press <Enter> to Quit'');
   readln();
end.



谢谢大家:rose:



thanks everyone:rose:

推荐答案

我们不为他们做家庭作业.这不是因为我们认为它在我们之下,而是因为如果 YOU 不自己做, YOU 不会学到任何东西.

We don''t do people''s homework for them. It''s not because we think it''s beneath us, but because if YOU don''t do it yourself, YOU won''t learn anything.


此人认为您拥有一个甚至不考虑运算符优先级的计算器.应用于输入22 + 3/5结果

This person thinks that you''ve got yourself a calculater that doesn''t even consider operator precedence. Applied to input 22+3/5 the outcome
is
writeln(((22+3)/5));


与以下内容完全不同:


which is quite different from:

writeln((22+(3/5)));


这就是我的想法!

干杯,

曼弗雷德(Manfred)


That''s what I think!

Cheers,

Manfred


是.

Yes.

writeln(22+3/5);


这篇关于帕斯卡问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆