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

所有测试数据通过无任何异常,谁能告诉我,为什么runtime error?!!!?!!!

Posted by yuanshi at 2006-09-13 02:22:57 on Problem 1007
#include<iostream>
#include<fstream>
using namespace std;
typedef struct 
{
	int key;
	int xiabiao;
}dna;

dna hehe[58];
int n,m;


int cmp( const void *a ,const void *b)
{ 
     return ((dna*)a)->key - ((dna*)b)->key ; 
}
int main()
{
	//ifstream cin("1007.in");
	//ofstream cout("1007.out");
	int i,j,r,k;
	char s[108][58];
	cin>>n>>m;
	for(i=0;i<m;i++)
		cin>>s[i];
	if(m==1)
	{
		cout<<s[0]<<endl;
		return 0;
	}
	for(i=0;i<m;i++)
	{
		for(r=0,j=0;j<n;j++)
		{
			for(k=j+1;k<n;k++)
				if(s[i][j]>s[i][k])
					r++;
		}
		hehe[i].key=r;
		hehe[i].xiabiao=i;
	}
	qsort(hehe,m,sizeof(hehe[0]),cmp);

	for(i=0;i<m;i++)
	{
		j=hehe[i].xiabiao;
		cout<<s[j]<<endl;
	}
	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