Start: Dec, 04, 2016 12:00:00
杭州师范大学第十届程序设计竞赛—正式
End: Dec, 04, 2016 17:00:00
Time elapsed:
Time remaining:

Problem_ID: F
Result: Accepted
Time: 1ms
Memory: 1092kB
In contest: 1075

#include<stdio.h>
#include<string.h>
#include<stdlib.h>

char comp(const void *p,const void *q);

int main(void)
{
	char str1[1000]={0};
	char str2[1000]={0};
	int l1,l2,l3,t=0;
	char s[2]={0};
	gets(s);
	switch(s[0]){
		case '1':
			t=1 ;
			break;
	case '2':
			t=2 ;
			break;
			case '3':
			t= 3;
			break;
			case '4':
			t= 4;
			break;
			case '5':
			t= 5;
			break;
			case '6':
			t= 6;
			break;
			case '7':
			t= 7;
			break;
			case '8':
			t= 8;
			break;
			case '9':
			t= 9;
			break;
	}

	while(t--){
		gets(str1);
		l1=strlen(str1);
		gets(str2);
		l2=strlen(str2);
		qsort(str1,l1,sizeof(char),comp);
		qsort(str2,l2,sizeof(char),comp);
		int n=0,l3;
		if(l1>l2)
			l3=l1;
		else
			l3=l2;
		for(int i=0;i<l3;i++){
			if(str1[i] != str2[i]){
				n= -1;
				break;
			}
			else if((str1[i]==' ')&&(str2[i]==' ')){
				n=0;
				break;
			}
	}
		if(n==0)
		{
			printf("Yes\n");
		}
		else 
			printf("No\n");
}
	return 0;

}

char comp(const void *p,const void *q)
{
	return (*(char *)q - *(char *)p);
}