According to their own thinking simple write a bit, a lot of communication.
#include "stdafx.h" int insertinorder (int *a,int num,int len) {//This method can be improved a lot, insert data, and then sort. int Position;if (a[0]==0) {A[0] = Num;position = 1;} for (int i = 0; i < len-1;i++) {if (Num>a[i] && num<a[i + 1]) {position = i + 2;for (int j = len-1; J > i+1;j--) {A[j] = a[j-1];} A[I+1] = num;break;} if (Num>a[i] && 0 = = a[i + 1]) {position = i + 2;a[i + 1] = Num;break;}} return position;} int _tmain (int argc, _tchar* argv[]) {int a[100] = {0};int b[] = {1, 2, 5, 8, ten, 4, 3, 6, 9, 7};int count = 0;int i = 0 int position;//at the beginning of the position to start from 1, but also with a lot of inconvenience. int len = sizeof (b)/sizeof (int), for (i = 1; I <= len; i++) {position = Insertinorder (a,b[i-1],i); if (count = = (Positio n-1) && Position = = A[position-1]) {printf ("%d,", a[position-1]); count++;for (int j = position + 1; J <= L En J + +) {if (a[j-1]==0) {break;} if (count = = (j-1) && j = = A[j-1]) {count++;//i++;p rintf ("%d,", a[j-1]);}} printf ("\ n");}} return 0;}
Ali pen questions, ordered sequence of sequential output.