I am getting an unusual result when attempting to place a value in an array. I have an array table[] of a simple class result{ int score, long time, string ID} Intention is to have a sort of leader board. My code happily finds the correct place to insert a new score if it is in the top 10.
int ix = 0;
int jx = 10; //
while ( ix < jx )
{
if (points > sTable[ix].points)
{
// score is higher move records down
for (jx = mNumRecords - 1; jx >ix ; jx--)
{
sTable[jx] = sTable[jx -1];
}
//now add new score
sTable[ix].score = score; // all good until here
sTable[ix].time = time;
}
ix++;
}
问题在于,当我试图用可衡量的[六]分点插入计分;
该数值为可兑换[ix]分,也为可兑换[ix +1]分。
重复的是,它以六分之一的价值发生,我通过该守则单行,只要我只能够告诉指挥员一次。
是否有人看到这一点?