#include
#include
int main(int argc, char *argv[]) {
int i, j;
int a[5]; //有错误
int temp;
printf(\请输入%d个数:\\n\ for (i = 0; i < N; i++) {
scanf(\ }
for (i = 1; i < N; i++)
{
for (j = 0; j <= N - 1; 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++) {
printf(\ }
printf(\ system(\
return 0; }
//有错误 应该为 j < N - 1
VC 6.0 运行结果截图:
Dev c++ 运行结果截图:
#include
#include
int main(int argc, char *argv[]) { int i, j;
int temp;
int a[3]; //有错误 明显的数组越界 int t;
printf(\请输入%d个数:\\n\
for (i = 0; i < N; i++) {
scanf(\ }
t = a[5];
printf(\ for (i = 0; i < N; i++) {
printf(\ }
for (i = 1; i < N; i++) {
for (j = 0; j < N - i; j++) //有错误 应该为 j < N - 1 {
if (a[j] > a[j + 1]) {
temp = a[j]; a[j ] = a[j + 1];
a[j + 1] = temp;
} } }
printf(\ for (i = 0; i < N; i++) {
printf(\ }
printf(\ printf(\
system(\ return 0; }
Dev c++
Vs 2010
Vc 6.0