?? 9.1.cpp
字號:
#include<iostream>
using namespace std;
template<typename T>
void paixu(T a[10])
{
T t;
for(int i=0;i<10;i++)
for(int j=0;j<9;j++)
if(a[j]>a[j+1])
{
t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
cout<<"從小到大排序:"<<endl;
for(int k=0;k<10;k++)
cout<<a[k]<<" ";
cout<<endl;
}
void main()
{
cout<<"輸入10個整型數"<<endl<<endl;
int a[10];
for(int l=0;l<10;l++)
{
cout<<"請輸入第"<<l+1<<"個整型數:";
cin>>a[l];
}
paixu(a);
cout<<endl;
cout<<"輸入10個字符"<<endl<<endl;
char b[10];
for(int k=0;k<10;k++)
{
cout<<"請輸入第"<<k+1<<"個字符:";
cin>>b[k];
}
paixu(b);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -