#include<iostream>#include<cstdio>using namespace std;template <typename T>void sort(T x,T y,T z){int t;if(x>y){t=x,x=y,y=t;}if(x>z){t=x,x=z,z=t;}if(y>z){t=y,y=z,z=t;}cout<<x<<"\t"<<y<<"\t"<<z<<endl;}int main(){int a,b,c;char str[3];double l,m,n;cin>>a>>b>>c;cin>>str;cin>>l>>m>>n;sort(a,b,c);sort(str[0],str[1],str[2]);sort(l,m,n);return 0;}這個程序有問題,但不知道問題在哪。。。原題:用函數模板template <typename T> void sort(T x,T y,T z)實現3個數值按最小值到最大值排序輸出的程序。第1行輸入int型3個數值,用空格分隔。第2行輸入char型3個數值,連續輸入,不用空格分隔。第3行輸入double型3個數值,用空格分隔。
- 2 回答
- 0 關注
- 628 瀏覽
添加回答
舉報
0/150
提交
取消
