for ( k = 1; k %26lt;= howmany; k++ )
{
for ( c = 2; c %26lt;= howmany + 1; c++ )
{
if ( taxes[k] %26gt; taxes[c] )
taxes[k] = taxtemp;
taxes[k] = taxes[c];
taxes[c] = taxtemp;
status_array[k] = statustemp;
status_array[k] = status_array[c];
status_array[c] = statustemp;
income_array[k] = incometemp;
income_array[k] = income_array[c];
income_array[c] = incometemp;
ssn_array[k] = ssntemp;
ssn_array[k] = ssn_array[c];
ssn_array[c] = ssntemp;
}
}
C++ Array Sorting Problem?
First your for loops should start with zero. Second you forgot the curly bracket after the if statement. Thirdly you should write a swap function and use that. :)
for( k=1; k %26lt;= howmany-1; k++ )
{
for( c=1; c %26lt;= howmany; c++ )
{
if( taxes[k] %26gt; taxes[c])
{
swap(%26amp;taxes[k], %26amp;taxes[c]);
swap(%26amp;status_array[k], %26amp;status_array[c]);
swap(%26amp;income_array[k], %26amp;income_array[c]);
swap(%26amp;ssn_array[k], %26amp;ssn_array[c]);
}
}
}
void function swap(int a, int b)
{
int temp = a;
a = b;
b = temp;
}
// I hope this helps :)
Reply:You may contact a c++ helper live at website
like http://ccietutorial.com/
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment