After reading your question 5 times I think I understand what u want.
I was going to try and clarify what you are trying to do better, but it is a rather tricky thing to explain ;P
This code produces the same output as your variable b.
#include <stdio.h>
#include <limits.h>
int main() {
int pGapArray[] = { 10, 7, 2, 3 };
int pNoGapArray[sizeof(pGapArray) / sizeof(pGapArray[0])];
int nLowestIdx = 0;
int nLowestVal = INT_MAX;
int nMinLowest = -1;
int nValue = 1;
for (int nIndex = 0; nIndex < sizeof(pGapArray) / sizeof(pGapArray[0]); ++nIndex) {
nLowestVal = INT_MAX;
for (int nSearch = 0; nSearch < sizeof(pGapArray) / sizeof(pGapArray[0]); ++nSearch) {
if (pGapArray[nSearch] < nLowestVal && pGapArray[nSearch] > nMinLowest) {
nLowestIdx = nSearch;
nLowestVal = pGapArray[nSearch];
}
}
nMinLowest = pGapArray[nLowestIdx];
pNoGapArray[nLowestIdx] = nValue++;
}
printf(" pGapArray[] = { ");
for (int nIndex = 0; nIndex < sizeof(pGapArray) / sizeof(pGapArray[0]); ++nIndex) {
printf("%d, ", pGapArray[nIndex]);
}
printf("};\n");
printf("pNoGapArray[] = { ");
for (int nIndex = 0; nIndex < sizeof(pNoGapArray) / sizeof(pNoGapArray[0]); ++nIndex) {
printf("%d, ", pNoGapArray[nIndex]);
}
printf("};\n");
return 0;
}