一个ESP8266的小项目
算法列表 |
void Insert(ElemType *A, ElemType num, int len) |
#include <iostream>
using namespace std;
#define ElemType int
void Insert(ElemType *A, ElemType num, int len)
{
for (int i = 0;i < len;i++)
{
if (A[i] > num)
{
for (int j = len;j >i;j--)
A[j] = A[j - 1];
A[i] = num;
break;
}
}
}
int main()
{
ElemType A[11] = { 3,5,7,9,13,23,27,29,38 };
int c = 0;
cin >> c;
Insert(A, c, 9);
for (int i = 0;i < 10;i++)
cout << A[i]<<" ";
getchar();
return 0;
}