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:我的代码,WA了~~~~哭死,不知道什么原有啊!能考虑都考虑到了,请高手指点一下呀~~~

Posted by ljl08 at 2007-07-24 06:21:01 on Problem 1007
In Reply To:Re:我的代码,WA了~~~~哭死,不知道什么原有啊!能考虑都考虑到了,请高手指点一下呀~~~ Posted by:ljl08 at 2007-07-24 06:18:41
我比较了下我们两的代码
除了一些输入输出不一样外,我用的c的输入,据说那样程序比较快
量程序过程基本都是一样的。
不过我没用快牌
按理应该没问题
不知道怎么回事总是wa郁闷的要死啊 。
有空帮我 看看啊
#include <stdio.h>
#include <string.h>
#define MAX 100000
int calculate(char *string,int n){
	int i,j,sort;
	char c;
	sort=0;
	for(i=0;i<n;i++){
		c=string[i];
		for(j=i+1;j<n;j++){
			if(c>string[j])++sort;
		}
	}
	return sort;
}
void main(){
	int n,m,i,*sorts;
	int min,j;
	char **strings,buf;
	scanf("%d%d",&n,&m);
	scanf("%f",&buf);
	strings =new char*[m];
	for(i=0;i<m;i++){
		strings[i]=new char [n];
		strcpy(strings[i],"");
		for(j=0;j<n;j++)
       		scanf("%c",&strings[i][j]);
		scanf("%c",&buf);
	}
	sorts =new int [m];
	for(i=0;i<m;i++){
		sorts[i]=0;
		sorts[i]=calculate(strings[i],n);
	}
	for(i=0;i<m;i++){
		min=0;
		for(j=0;j<m;j++){
			if(sorts[j]<sorts[min]){
				min=j;	
			}
		}
		printf("%s\n",strings[min]);
		sorts[min]=MAX;
	}
	for(i=0;i<m;i++)delete [] strings[i];
	delete[] strings;
	delete [] sorts;
}

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