#include
using namespace std;
int main()
{
int a[10]={1,-2,3,-4,-5,6,7,-8,9,-10},t,i;
int *p,*q;
p=a;
q=&a[9];
while(p{
if((*p)>0&&(*q)<0)
{
*p=t;
*p=*q;
*q=t;
}
q--;
p++;
}
for(i=0;i<10;i++)
cout<<a[i]<<" ";
cout<<endl;
return 0;
}
变量互换有错误应该是t=*p,循环条件也不明确,你在搞什么?
return 0当然是0啊
return 0表示该函数执行完后返回一个值0
为什么 是 输出 1和3
还没看出来
while如果是p读完a看起来是输出
1 9 3 7 6 -5 -4 -8 -2 -10
为什么 是 输出 1和3
循环出错误了,