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 wlz at 2008-12-03 23:19:47 on Problem 1617
样例过了啊,感觉也没什么问题了啊……
#include <iostream>
#include <string>
#include <stdlib.h>
struct node {
	int w;
	int index;
}key[11];
int cmp(const void *a,const void *b) {
	struct node *aa=(node *)a;
    struct node *bb=(node *)b;
	if(aa->w==bb->w) return 1;
	else return(aa->w-bb->w);
}
int main()
{
	char in[200],ans[20];
	char out[200][200];
	int i,j,k,len,flag,len1;
	while(scanf("%s",&ans)) {
		if(strcmp(ans,"THEEND")==0) break;
		len=strlen(ans);
		for(i=0;i<len;i++) {
			key[i].w=(int)(ans[i]-'0');
			key[i].index=i+1;
		}
		qsort(key,len,sizeof(key[0]),cmp);
		scanf("%s",&in);flag=0;len1=strlen(in)/len;
		for(j=0;j<len;j++) {
			for(k=0;k<len1;k++) {
				out[k][(key[j].index)-1]=in[flag++];
			}
		}
		for(i=0;i<len1;i++)
			for(j=0;j<len;j++)
				printf("%s",out[i][j]);
		printf("\n");
	}
	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