高手帮忙…………
我是c++刚入门、希望各位高手能帮我看看是什么情况……题目是这样的:分别对三个整数,三个实数,三个字符从小到大排序输出。要求:用重载函数实现。
下面是我的代码……
#include< iostream>
using namespace std;
int main ()
{
int a[3];
float b[3];
char c[3];
int i;
for ( i = 1 ; i <= 3 ; i++ )
{
cin >> a[i];
cin >> b[i];
cin >> c[i];
}
int z;
z = line( a[1] , a[2] , a[3] );
cout << a[1] << a[2] << a[3] << endl;
float s;
s = line( b[1] , b[2] , b[3] );
cout << b[1] << b[2] << b[3] << endl;
char f;
f = line( c[1] , c[2] , c[3] );
cout << c[1] << c[2] << c[3] << endl;
return 0;
}
int line( int a[1] , int a[2] , int a[3] )
{
int i , j , k;
for ( i = 1 ; i <= 3 ; i++ )
{
for ( j = i -1 ; j <= 3 ; j++)
{
if ( a[i] > a[j] )
{
k = a [j];
a[j] = a [i];
a[i] = k;
}
}
}
}
float line( float b[1] , float b[2] , float b[3] )
{
float i , j , l;
for ( i = 1 ; i <= 3 ; i++ )
{
for ( j = i -1 ; j <= 3 ; j++)
{
if ( b[i] > b[j] )
{
l = b[j];
b[j] = b[i];
b[i] = l;
}
}
}
}
char line( char c[1] . char c[2] , char c[3] )
{
char i , j , m;
for ( i = 1 ; i <= 3 ; i++ )
{
for ( j = i -1 ; j <= 3 ; j++)
{
if ( c[i] > c[j] )
{
m = c[j];
c[j] = c[i];
c[i] = m;
}
}
}
}