输入三个整数a,b,c设计一个算法使得输入的三个整数按从小到大的次序分别存放在变量a,b,c中。
要求:运行时单击窗体按序弹出三个inputbox输入框,计算后直接在窗体上打印出a,b,c三个变量的值...
要求:运行时单击窗体按序弹出三个inputbox输入框,计算后直接在窗体上打印出a,b,c三个变量的值
展开
展开全部
用C++编写:
#include<iostream>
using namespace std;
int main()
{
int a,b,c,temp;
cout<<"请输入三个数:";
cin>>a>>b>>c;
cout<<"排序之前的值为:";
cout<<"a="<<a<<" b="<<b<<" c="<<c<<endl;
if(a>b)
{
temp=a;
a=b;
b=temp;
}
if(a>c)
{
temp=a;
a=c;
c=temp;
}
if(b>c)
{
temp=b;
b=c;
c=temp;
}
cout<<"排序后的值为:";
cout<<"a="<<a<<" b="<<b<<" c="<<c<<endl;
}
#include<iostream>
using namespace std;
int main()
{
int a,b,c,temp;
cout<<"请输入三个数:";
cin>>a>>b>>c;
cout<<"排序之前的值为:";
cout<<"a="<<a<<" b="<<b<<" c="<<c<<endl;
if(a>b)
{
temp=a;
a=b;
b=temp;
}
if(a>c)
{
temp=a;
a=c;
c=temp;
}
if(b>c)
{
temp=b;
b=c;
c=temp;
}
cout<<"排序后的值为:";
cout<<"a="<<a<<" b="<<b<<" c="<<c<<endl;
}
追问
用VB编写怎么办
追答
这个就不清楚了
展开全部
Sub test()
Dim arr(1 To 3) As Integer
Dim i As Integer
Dim a As Integer, b As Integer, c As Integer
Dim x As String
For i = 1 To 3
arr(i) = InputBox("请输入第 " & i & " 个值:")
Next i
a = Application.WorksheetFunction.Small(arr, 1)
b = Application.WorksheetFunction.Small(arr, 2)
c = Application.WorksheetFunction.Small(arr, 3)
x = "a=" & a & vbCrLf & "b=" & b & vbCrLf & "c=" & c
MsgBox x
End Sub
Dim arr(1 To 3) As Integer
Dim i As Integer
Dim a As Integer, b As Integer, c As Integer
Dim x As String
For i = 1 To 3
arr(i) = InputBox("请输入第 " & i & " 个值:")
Next i
a = Application.WorksheetFunction.Small(arr, 1)
b = Application.WorksheetFunction.Small(arr, 2)
c = Application.WorksheetFunction.Small(arr, 3)
x = "a=" & a & vbCrLf & "b=" & b & vbCrLf & "c=" & c
MsgBox x
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
单击窗体?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询