为什么自定函数没有起作用?

发布时间:2024-05-14 18:26 发布:上海旅游网

问题描述:

自定了排序函数sorth,为什么无法正确显示呢?我调试过函数确实起作用,VC也显示无错误,就是无法改变main()函数中的值
程序如下:
#include<iostream>
using namespace std;
void sorth(int m1,int m2)
{
int temp;
if(m1>m2)
{
temp=m1;
m1=m2;
m2=temp;
}
}
void main()
{
int a,b,c;
cout<<"please input 3 numbers"<<endl;
cin>>a>>b>>c;
sorth(a,b);
sorth(a,c);
sorth(b,c);
cout<<"the sorth is "<<a<<","<<b<<","<<c<<endl;
}

问题解答:

为什么自定函数没有起作用?这个旅游问答期待您的解答,请登录账号或关注微信公众号回答这个问题。

热点新闻