#include <iostream>
#include <string>
using namespace std;
int main()
{
long c[5]={10100,-123567, 1198783,-165654, 3456};
int a[5]={1,9,0,23,-45};
float b[5]={2.4, 7.6, 5.5, 6.6, -2.3 };
void sort(int []);
void sort(float []);
void sort(long []);
sort(a);
sort(b);
sort(c);
return 0;
}
void sort(int a[])
{int i,j,t;
for (j=0;j<5;j++)
for(i=0;i<5-j;i++)
if (a[i]>a[i+1])
{t=a[i];a[i]=a[i+1];a[i+1]=t;}
cout<<"the sorted numbers :"<<endl;
for(i=0;i<5;i++)
cout<<a[i]<<" ";
cout<<endl<<endl;
}
void sort(long a[])
{int i,j;
long t;
for (j=0;j<5;j++)
for(i=0;i<5-j;i++)
if (a[i]>a[i+1])
{t=a[i];a[i]=a[i+1];a[i+1]=t;}
cout<<"the sorted numbers :"<<endl;
for(i=0;i<5;i++)
cout<<a[i]<<" ";
cout<<endl<<endl;
}
void sort(float a[])
{int i,j;
float t;
for (j=0;j<5;j++)
for(i=0;i<5-j;i++)
if (a[i]>a[i+1])
{t=a[i];a[i]=a[i+1];a[i+1]=t;}
cout<<"the sorted numbers :"<<endl;
for(i=0;i<5;i++)
cout<<a[i]<<" ";
cout<<endl<<endl;
}
1.13
最新推荐文章于 2024-04-05 18:48:25 发布