insert.cpp
来自「将某个数或字符按照某种规律插入一列数或字符中」· C++ 代码 · 共 32 行
CPP
32 行
//////////////////////////////////////////////////////////////////////////////////
////////file: Insert.cpp
//suppose that the oringinal order is from the min to the max
#include <iostream.h>
void main()
{
int n;
int s[7]={12,23,34,45,56,67,78};
cout<<"input a int:"<<endl;
cin>>n;
int t[8];
int i=0;
for(; i<7; i++)
{
if(n>=s[i]) t[i]=s[i];
else
{
t[i]=n;
break;
}
}
for(i; i<7; i++)
{
t[i+1]=s[i];
}
if(n>=s[6]) t[7]=n;
for(int x=0; x<8; x++)
cout<<t[x]<<" ";
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?