请大神帮我看看这段程序哪里出错了??谢谢!

2025-05-16 11:08:33
推荐回答(3个)
回答(1):

#include
#include
using namespace std;
void sort1(int arraya[],int n)
{
for(int i=0;i<=n-1;i++)
{
for(int j=0;j {
if (arraya[j]>arraya[j+1])
{
int temp=0;
temp=arraya[j];
arraya[j]=arraya[j+1];
arraya[j+1]=temp;
}
}
}
}
int main()
{
int a[]={2,1,4,3,7,5,8,6};
int n=sizeof(a)/sizeof(int);
sort1(a,n);
for(int i=0;i<=n-1;i++)
{
cout< }
cout< return 0;
system("pause");
}

 

回答(2):

int temp=0;
这里应该在函数最开始的时候定义吧,不应该在中间定义。

回答(3):

文件出错了 修复看看