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

Re:Output limit exceeded 是怎么回事?

Posted by jean890915 at 2011-10-04 20:30:43 on Problem 1007
In Reply To:Output limit exceeded 是怎么回事? Posted by:2009302505 at 2011-06-27 11:43:35
> 这是什么类型的错误?我觉得好像我的结果是对的。
> 详细:排序用的是冒泡,其他很简单。
> 不知道这道题排序要求是什么,是当逆序数相同时后出现的先输出吗?
我的也是!!

#include "iostream"
using namespace std;

#define N 50
#define M 101

int DNA_inv(char a[],int m)
{
	int i,j,sum=0;
	for (i=0;i<m-1;i++)
	{
		for (j=i+1;j<m;j++)
		{
			if (a[i]>a[j])
				sum++;
		}
	}
	return sum;
}

typedef struct node
{
	int x;
	int y;
}my_struct;

void insert_sort(my_struct a[],int m)
{
	int i,j;
	for(i=2;i<=m;i++)
	{
		a[0] = a[i];
		j = i-1;
		while (a[0].y<a[j].y)
			a[j+1] =a[j--];
		a[j+1] = a[0];
	}
}

void DNA(void)
{
	int m,n,i;
	char str[M][N];
	my_struct b[M];
	cin>>m>>n;
	for (i=1;i<=n;i++)
	{
		cin>>str[i];
		b[i].x = i;
		b[i].y = DNA_inv(str[i],m);
	}
	insert_sort(b,n);
	for (i=1;i<=n;i++)
	{
		cout<<str[b[i].x]<<endl;
	}
}

int main(void)
{
	DNA();
	return 0;
}
		

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