如何将一个数据插入到一个有序的数组中?用C++写出来

2024-12-26 11:40:30
推荐回答(1个)
回答1:

#include
#include
#include
#include
#include using namespace std;int main()
{
//数组大小看你数字长度定义
char num[30];
cout << "input number: ";
int i = 0, len = 0;
gets(num);
len = strlen(num);
vector ivec(num, num + len);
sort(ivec.begin(), ivec.end());
vector::iterator it = ivec.begin();
while( it != ivec.end())
cout << static_cast(*it++);
cout << endl;
system("pause");
return 0;
}