zz_2.cpp
来自「判断素数的简单应用,从1到100可以全部显示出来而且可一按10个一行规格输出!」· C++ 代码 · 共 47 行
CPP
47 行
#include <iostream.h>
class panxu
{
public:
void set_value();
void array_value();
void show_value();
private:
int array[10];
};
void panxu::set_value()
{
int i;
cout<<"input ten numbers:"<<endl;
for(i=0;i<10;i++)
cin>>array[i];
}
void panxu::array_value()
{
int i,j,temp;
for(i=0;i<10;i++)
for(j=i+1;j<10;j++)
if(array[i]>=array[j])
{
temp=array[i];
array[i]=array[j];
array[j]=temp;
}
}
void panxu::show_value()
{
int i;
cout<<"从小到大顺序是:"<<endl;
for(i=0;i<10;i++)
cout<<array[i]<<" ";
cout<<endl;
}
int main()
{
panxu t1;
t1.set_value();
t1.array_value();
t1.show_value();
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?