Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

为什么编译都通过不了啊.大虾帮我看看.

Posted by ainibaobao at 2005-07-26 09:42:45 on Problem 1007
#include <iostream.h>
#include <string.h>
void bubblesort(int r[],char **p,int m); 
void main()
{
	int m;       //数组个数 
	int n;       //数组长度
	int i;
	int j;
	int k;
	char **p;
	int  *p_num;
	int  *sort;
	cin>>n>>m;
	cin.get();
	p = new char*[m];
	p_num = new int[m];
	sort = new int[m];
	for(i = 0;i < m;i++)
	{
		p[i] = new char[n+1];
	}
	for(i = 0;i < m;i++)
	{
		cin.getline(p[i],n+1);
		cin.get();
	}
	for(i = 0;i < m;i++)
	{
		p_num[i] = 0;
	}
	for(i = 0;i < m;i++)
	{
		for(k = 0;k < n;k++)
		{
			for(j = k;j < n;j++)
			{
				if(int(p[i][k]) > int(p[i][j]))
				{
					p_num[i]++;
				}
			}
		}
	}
	cout<<endl;
	bubblesort(p_num,p,m);
	for(i = 0;i < m;i++)
	{
		for(j = 0;j < m;j++)
		{
			cout<<p[i][j];
		}
		cout<<endl;
	}
	delete []p;
	delete []p_num;
	delete []sort;
}
void bubblesort(int r[],char **p,int m)
{
	char *p_temp;
	p_temp = new char[m];
	int i,j,exchange;
	for (i = 0;i < m;i++)
	{
		exchange = 0;
		for (j = m;j >= i+1;j--)
		{
			if (r[j] < r[j - 1])
			{
				strcpy(p_temp,p[j]);
				strcpy(p[j],p[j-1]);
				strcpy(p[j-1],p_temp);
				exchange = 1;
			}
		}
		if(exchange == 0)
		{
			return;
		}
	}
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator