我创建了动态数组。如果用某些值填充。打印它。但是在交换/交换指针之后(任务是在某些条件下交换行)
条件取决于sumL
。为了不浪费你的时间,我没有描述细节。
问题在于交换指针。
for ( k = 0; k < N - 1; k++ )
{
for ( i = 0; i < N - 1; i++
if (sumL[i] > sumL[i+1])
{
temp = sumL[i]; // works
sumL[i] = sumL[i+1];
sumL[i+1] = temp;
temp = *a[i]; // doesn't work. Array is not the same: elements
a[i] = a[i+1]; // contain other values.
*a[i+1] = temp; /* What is wrong? */
}
}