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 msi at 2005-03-25 21:42:34 on Problem 1007
/*DNA排序*/
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <string.h>


#define MAX 10000000

typedef struct
{
	char *ch;
	int  *res;
}DNA_info;

DNA_info *di;

void cat(int n, int m, DNA_info *di)
{
	int i,j,k,sum;
	for(i=0;i<m;i++)
	{
		sum=0;
		for(j=0;j<n;j++)
		{
			if(di[i].ch[j]=='A')
				continue;
			else
			{
				for(k=j+1;k<n;k++)
					if(di[i].ch[k]<di[i].ch[j])
						sum+=1;
			}
		}
		*di[i].res=sum;
	}
}

void out(DNA_info *di, int m)
{
	int i,j,No,Res;

	for(i=0;i<m;i++)
	{
		No=0;
		Res=*di[0].res;
		for(j=0;j<m;j++)
		{
			if(*di[j].res<Res)
			{
				No=j;
				Res=*di[No].res;
			}
		}
		*di[No].res=MAX;
		printf("%s\n",di[No].ch);
	}
}

int main(int argc, char** argv)
{
	
	int m, n=10,i;
	char ch;
	scanf("%d%d",&n,&m);
	di=(DNA_info*)malloc(sizeof(DNA_info)*m);
	for(i=0;i<m;i++)
	{
		di[i].ch=(char*)malloc(sizeof(char)*(n+1));
		di[i].res=(int*)malloc(sizeof(int));
		scanf("%s",di[i].ch);
		gets(&ch);
		*di[i].res=0;
	}
	printf("\n");
	cat(n,m,di);
	out(di,m);
	for(i=0;i<m;i++)
	{
		free(di[i].ch);
		free(di[i].res);
	}
	free(di);
	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