麻烦分析一下结果.
课本上是这样子输入的,原理是啥呢?
详细一点,注意看一下编译器的版本
#include <iostream>
using namespace std;
void sort(int x, int y, int z);
int main() {
int x, y, z;
cin >> x >> y >> z;
sort(x, y, z);
return 0;
}
void sort(int x, int y, int z) {
int temp;
if (x > y) {
temp = x;
x = y;
y = temp;
}
if (z < x) {
cout << z << ',' << x << ',' << y << endl;
} else if (z < y) {
cout << x << ',' << z << ',' << y << endl;
} else {
cout << x << ',' << y << ',' << z << endl;
}
}
函数声明的位置不对,你放在main函数里面声明不行;
还有,记得以后贴代码,方便答题的人给你代码。
如有帮助,望采纳