话不多说,直接上代码吧,一看就懂。
实现的功能:数组内的元素颠倒顺序。
int test[5] = {1,4,2,7,6};
int tem,i,j;
for (j = 0, i = 4; j < i; --i, ++j)//注意看这里
{
tem = test[i];
test[i] = test[j];
test[j] = tem;
}
return 0;
完了。
话不多说,直接上代码吧,一看就懂。
实现的功能:数组内的元素颠倒顺序。
int test[5] = {1,4,2,7,6};
int tem,i,j;
for (j = 0, i = 4; j < i; --i, ++j)//注意看这里
{
tem = test[i];
test[i] = test[j];
test[j] = tem;
}
return 0;
完了。