这个程序为什么运行不了?
求大佬解答```C++
#include
#include
using namespace std;
int main()
{
int p(int *q,int n);
double p(double *q,int n);
float p(float *q,int n);
int i;
int a,n;
cout <<"请选择输入数据的类型:\n(1)整形\n(2)单精度\n(3)双精度\n";
cout <<"请输入类型前的编号:\n";
cin >>a;
cout <<"请输入您需要的数的个数:\n";
cin >>n;
cout <<"请输入"< if (a==1)
{
int *q=new int [n];
for (int i=0;i cin >>q[i];
p(q,n);
}
if(a==2)
{
double *q=new double [n];
for (int i=0;i cin >>q[i];
p(q,n);
}
if(a==3)
{
float *q=new float [n];
for (int i=0;i cin >>q[i];
p(q,n);
}
return 0;
}
int p(int *q,int n)
{
for (int i=0;i for (int j=0;j=n;j++)
if (q[i]>q[j])
{
int x;
x=q[i];
q[i]=q[j];
q[j]=x;
}
for (int k=0;k cout return 0;
}
double p(double *q,int n)
{
for (int i=0;i for (int j=0;j=n-i;j++)
if (q[j]>q[j+1])
{
double x;
x=q[j];
q[j]=q[j+1];
q[j+1]=x;
}
for (int k=0;k cout return 0;
}
float p(float *q,int n)
{
for (int i=0;i for (int j=0;j=n-i;j++)
if (q[j]>q[j+1])
{
float x;
x=q[j];
q[j]=q[j+1];
q[j+1]=x;
}
for (int k=0;k<n;k++)
cout <<q[k]<<" "<<endl;
return 0;
}
可以问一下这是什么意思???for (int i=0;i for (int j=0;j=n;j++)
你们代码里面很多语法错误,双重for循环第一重写了一半另一半呢???
你定义的:int p(int *q,int n);
double p(double *q,int n);
float p(float *q,int n);
不应该放在int main()中,应该放在它的上面
还有,你还缺失了很多“;”
你写for循环的时候下面的语句最好用{}括起来,就算是一句,这样看起来也整洁
最后,你的代码粘贴过来的时候有没有可能乱了,反正很多语法错误!!!