冒泡排序问题

来源:百度知道 编辑:UC知道 时间:2024/05/10 05:26:03
#include "stdafx.h"
#include<iostream>
#define N 5
using namespace System;
using namespace std;
void main()
{
int a[5]={6,8,2,4,9},i;
cout<<"排序前"<<endl;
for(i=0;i<N;i++)
cout<<" "<<a[i];
cout<<"排序后"<<endl;
maopaosort(a,5);
for(i=0;i<N;i++)
cout<<" "<<a[i];
}
void maopaosort(int a[],int N)
{
int i,j,temp;
for(i=0;i<N;i++)
for(j=0;j<N-i-1;j++)
if(a[j]<a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}

、、、、、、、、、、、、、、、、、、、、、、、、、、、
编译不通过,请问哪里错了??

#include<iostream>
#define N 5
using namespace std;

void maopaosort(int [], int);

void main()
{
int a[5]={6,8,2,4,9},i;
cout<<"排序前"<<endl;
for(i=0;i<N;i++)
cout<<" "<<a[i];
cout<<endl;
cout<<"排序后"<<endl;
maopaosort(a,N);
for(i=0;i<N;i++)
cout<<" "<<a[i];
cout<<endl;
}

void maopaosort(int a[], int n)
{
int i,j,temp;
for(i=0;i<n;i++)
for(j=0;j<n-i-1;j++)
if(a[j]<a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}

#include "stdafx.h" ,using namespace System; 没有必要写。