⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xt1-17-1.cpp

📁 c++的一些程序练习
💻 CPP
字号:
#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;
}



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -