求a、b、c中的最大数与最小数,并求出差?

mouse0987 2006-06-29 02:38:07
求a、b、c中的最大数与最小数,并求出差?
希望能用最简单的方法编写出来。谢谢!
...全文
186 6 打赏 收藏 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
mouse0987 2006-06-29
  • 打赏
  • 举报
回复
谢谢各位了,分虽少!可我的感激之情至真!!
mouse0987 2006-06-29
  • 打赏
  • 举报
回复
谢谢楼上的。我自己也编出来了。不过分还是要给你的,虽然少了点。不过我只有10分了。
互相学习!

<%
a=4
b=1
c=6

if a>b then
min=b
if min<c then
min=min
else
min=c
end if
max=a
if max>c then
max=max
else
max=c
end if
else
min=a
if min<c then
min=min
else
min=c
end if
max=b
if max>c then
max=max
else
max=c
end if
end if
l=max-min
response.write "max:"&max
response.write "min:"&min
response.write "kuaj:"&kuaj
response.end
%>
cestar2005 2006-06-29
  • 打赏
  • 举报
回复
直接在输入框写的,没有测试过,希望运行正确
meizz 2006-06-29
  • 打赏
  • 举报
回复
JS:
var min = Math.min(a, b, c);
var max = Math.max(a, b, c);

alert(max-min)
「已注销」 2006-06-29
  • 打赏
  • 举报
回复
ab=a-b
bc=b-c

if ab>=0 and bc>=0 then
a是最大的
c是最小的
ab+bc是最大最小的差
elseif ab>=0 and bc<=0 then
if ab+bc>=0 then
a最大,b最小,ab是差
else
c最大,a最小,-bc是差
end if
elseif ab<0 and bc<0 then
c最大,a最小,-ab-bc是差
elseif ab<0 and bc>0 then
if ab+bc>=0 then
b最大,c最小,bc是差
else
b最大,a最小,-ab是差
end if


--------------------------

哈哈,好玩吧?

--------------------------
sub swap(byref a,byref b)
a=a+b
b=a-b
a=a-b
end sub

if a>b then swap a,b
if b>c then swap b,c
if a>b then swap a,b

---------------------

两次冒泡~~呵呵
cestar2005 2006-06-29
  • 打赏
  • 举报
回复
LZ让我想起了第一次上C语言课时的情景,谭浩强教授出的那本,好像里面有一个差不多的例子
现在我用ASP来改写下,如果没记错的话:
<%
a=3
b=1
c=5
if a<b then
temp=a
a=b
b=temp
end if
if a<c then
temp=a
a=c
c=temp
end if
if b<c then
temp=b
b=c
c=temp
end if
Response.write "最大:"&a&"最小:"&c
Response.write "差:"&a-c
%>

28,402

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧