Hi guys
I tried to convert this c++ code to c shell script but there are some bugs and I don't know how to solve it.
This code prints the three variables in decreasing order:
int main()
{
int x,y,z;
cin >> x >> y >>z;
if ( x < y )
if ( x < z )
if ( y < z )
cout << x <<" " << y <<" "<< z << endl;
else
cout << x <<" "<< z <<" "<< y << endl;
else
cout << z <<" "<< x <<" "<< y << endl;
else
if ( y < z )
if ( x < z )
cout << y <<" "<< x <<" "<< z << endl;
else
cout << y <<" "<< z <<" "<< x << endl;
else
cout << z <<" "<< y <<" "<<x << endl;
return 0;
}
Here is my try:
#!/bin/csh
if ( $1 < $2 ) then
if ( $1 < $3 ) then
if ( $2 < $3 ) then
echo $1" "$2" "$3
else
echo $1" "$3" "$2
else
echo $3" "$1" "$2
else
if ( $2 < $3 ) then
if ( $1 < $3 ) then
echo $2" "$1" "$3
else
echo $2" "$3" "$1
else
echo $3" "$2" "$1