C++排序问题,编译连接都没错,为啥运行不对???

[复制链接]
查看11 | 回复4 | 2011-3-2 11:39:06 | 显示全部楼层 |阅读模式
#include
using namespace std;
void Sortint(int a[],int n)
{
int t;
for(int i=0;i>b;
Sortint(b,5);
return 0;
}

回复

使用道具 举报

千问 | 2011-3-2 11:39:06 | 显示全部楼层
你的程序的问题是没有输出。你确实进行了排序操作,但是并没有把结果输出出来。我帮你改了下,你看看。在VC++6.0下编译运行均没有问题。#includeusing namespace std;void Sortint(int a[],int n){ int t; for(int i=0;i<n-1;i++) {for(int j=i+1;j<n;j++){ if(a[j]<a)
{
t=a;
a = a[j];
a[j] = t; }} }}int main(){ int b[5],m
回复

使用道具 举报

千问 | 2011-3-2 11:39:06 | 显示全部楼层
呵呵 你怎么知道不对的
回复

使用道具 举报

千问 | 2011-3-2 11:39:06 | 显示全部楼层
你的代码是对的,只是没有输出#includeusing namespace std;void Sortint(int a[],int n){ int t; for(int i=0;i<n-1;i++) {for(int j=i+1;j<n;j++){ if(a[j]<a)
回复

使用道具 举报

千问 | 2011-3-2 11:39:06 | 显示全部楼层
if ((fp=fopen("c:\\2.txt","r"))==NULL)比较时用 ==
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行