C++问题输入10个整数

来源:百度知道 编辑:UC知道 时间:2024/06/28 06:29:18
#include<iostream>
using namespace std;
int main()
{void shuru(int *a);
void shuchu(int *b);
void chuli(int *c);
int a[10],*q;
q=a;
shuru(q);
chuli(q);
shuchu(q);
return 0;
}
void shuru(int *a)
{
int i;
for(i=0;i<10;i++)
cin>>*(a+i);
}
void shuchu(int *b)
{
int i;
for(i=0;i<10;i++)
cout<<*(b+i);
}
void chuli(int *c)
{
int d,x,i,temp,temp2;
for(i=0;i<10;i++)
{if(*(c+i)>*((c+i)+1))d=i;
if(*(c+i)<*((c+i)+1))x=i;
}
{temp=*c;*c=*(c+d);*(c+d)=temp;}
{temp2=*(c+9);*(c+9)=*(c+x);*(c+x)=temp2;}
}
我怎么结果比如说,要输入
1,2,3,60,5,6,7,-30,9,10
应该得到
60,2,3,1,5,6,7,10,9,-30

我怎么输入1,2,3,60,5,6,7,-30,9,10
还是输出1,2,3,60,5,6,7,-30,9,10
该怎么办啊

谢谢了,
#include<iostream>
using namespace std;
int main()
{void shuru

void chuli(int *c)
{
int d,x,i,temp,temp2;
for(i=0;i<10;i++)
{if(*(c+i)>*((c+i)+1))d=i;
if(*(c+i)<*((c+i)+1))x=i;
//问题出在这里 大括号打错地方了 for循环体应该包括下面两行
{temp=*c;*c=*(c+d);*(c+d)=temp;}
{temp2=*(c+9);*(c+9)=*(c+x);*(c+x)=temp2;}
}
}

排序函数有误