Just had to limit the inner loop to <9.
The fixed code:
for(int i=0;i<10;i++) //1st array, ascending
{
for(int j=0;j<9;j++)
{
if(array1[j]>array1[j+1])
{
int temp=array1[j];
array1[j]=array1[j+1];
array1[j+1]=temp;
}
}
} //Over
for(int i=0;i<10;i++) //2nd array, descending
{
for(int j=0;j<9;j++)
{
if(array2[j]<array2[j+1])
{
int temp=array2[j];
array2[j]=array2[j+1];
array2[j+1]=temp;
}
}
} //Over
Thank you guys!
solved Sorting two arrays in c++ [closed]