- 论坛徽章:
- 0
|
囧..CU的a[i]打不出来,你的代码里面那两处a[i]到底是显示不出来还是什么问题?
#include<iostream>
using namespace std;
#define N 10
void PaiXu(int *a) //对10个数排序
{
int i, j;
int temp;
for (i = 0; i < N; i++)
for (j = 0; j < N - i; j++)
{
if (a[j] > a[j + 1])
{
temp = a[j];
a[j] = a[j + 1];
a[j + 1] = temp;
}
}
for (i = 0; i < N; i++)
cout << a[i] << " ";
cout << endl;
}
int main()
{
int i, j, x;
int a[N];
cout << "请输入10个数:" << endl;
for (i = 0; i < N; i++)
cin >> a[i];
cout << endl;
for (j = 0; j < N; j++)
cout << a[j] << " ";
cout << endl;
cout << "排序后的数组为:" << endl;
PaiXu(a);
return 0;
} |
这个代码反正是能通过编译的 |
|