if语句和case语句 急急急 在线等

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了if语句和case语句 急急急 在线等相关的知识,希望对你有一定的参考价值。

先是if语句
编写程序,当输入x后输出y的值
y= x x<0
10 0<=x<=20
-0.5x+20 x>20
分别用
(1)不嵌套的语句
(2)嵌套在then子句中的if语句
(3)嵌套在else子句中的if语句

再是case语句
某幼儿园只收2-6岁的小孩
2-3岁入小班(enter lower class);
4岁入中班(enter middle class);
5-6岁入大班(enter higher class);
编写程序输入年龄,判断小孩入学情况.

高手帮忙...
第一题意思就是:如果x<0,那么y=x
如果0≤x≤20,那么y=10
如果x>20,那么y=-0.5x+20
下面三小题要分开来写
而且都要用pascal语言写

我看了一下前三个答案
2.3好象都有错呃..

参考技术A 1.(1)var x,y integer;
begin
repeat
readln(x,y);
write(x,' ')
if x<0 then writeln(x);
if(x>=0)and(x<=20) then writeln('10');
if x>20 then writeln(-0.5*x+20);
until eof;
end.
(2)var x,y integer;
begin
repeat
readln(x,y);
write(x,' ')
if x<0 then writeln(x);
if x>=0 then
if x>20 then writeln(-0.5*x+20) else writeln('10');
until eof;
end.
(3)
var x,y integer;
begin
repeat
readln(x,y);
write(x,' ')
if x<0 then writeln(x) else
begin
if(x>=0)and(x<=20) then writeln('10') else
if x>20 then writeln(-0.5*x+20);
end;
until eof;
end.

2.var n:integer;
begin
repeat
readln(n);
case n of
2..3:writeln('enter lower class');
4:writeln('enter middle class');
5..6:writeln('enter higher class');
else writeln('can not enter');
end;
until eof;
end.
参考技术B 1.input x
if x<0 then
y=x
end if
if x>=0 or x<=20 then
y=10
end if
if x>20 then
y=-0.5*x+20
end if
print y
2.input x
if x>=0 then
if x<=20 then y=10
else y=-0.5*x+20
end if
else y=x
end if
print y
3.input x
if x<0 then
y=x
else
if x>20 then
y=-0.5*x+20
else y=10
end if
end if
print y

input x
select x
case 2 to3
print"enter lower class"
case 4
print"enter middle class"
case 5to 6
print"enter higher class"
end select本回答被提问者采纳
参考技术C 一题:
var x,y:real;
begin
readln(x);
if x>=0 then
if x<=20 then y:=10
else y:=-(0.5*x)+20
else if x<0 then y:=x;
writeln(y);
end.

二题:
var yo:integer;
begin
readln(yo);
case yo of
2,3:writeln('enter lower class');
4:writeln('enter middle class');
5,6:writeln('enter higher class);
end;
end.
参考技术D 能不能具体解释一下第一题,完全看不懂

第二题容易

通达OA系统客户机无法登陆求高手赐教谢谢在线等急急急。

通达OA2009办公系统。下载的机器完全可以登陆。其他机器却无法登陆OA界面,防火墙以及局域网全是通的。请求高手赐教。现在没分了。以后补上 。谢谢了。在线等呢。。比较急

参考技术A 防火墙设置允许apache访问网络,并开放OA端口。可以停止防火墙,测试是不是防火墙影响。 参考技术B 用的谁的主机呀! 主机限制了IP了吗 换电脑试试 是不是有人恶意攻击了你的系统! 被主机自动限制了

以上是关于if语句和case语句 急急急 在线等的主要内容,如果未能解决你的问题,请参考以下文章

我可以使用带有两个变量的 case/switch 语句吗?

if语句中可以没有case

在C++中if语句和case语句哪一个执行效率更高

第二次实验报告

case语句

switch case语句和if的区别