# UVa 1339 sort ent Cipher [sort], 1339 cipher

Source: Internet
Author: User

UVa 1339 sort ent Cipher [sort], 1339 cipher

/*
You can see if you can change the location of the first character to exactly match the 26 letters of the second character.
Solution: count the number of characters in two strings. If the number of characters in each string is the same, yes is output; otherwise, no is output.
Difficulties: it is a little difficult to count the number of times each character appears.
Key Point: Sorting
Problem solving person: lingnichong
Solution time:
Experience in solving problems: a good question
*/

 1339-maximum ent CipherTime limit: 3.000 seconds

`#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;char cot1[300],cot2[300];int a[30],b[30];int main(){int i,l,len1,len2;while(~scanf("%s%s",cot1,cot2)){memset(a,0,sizeof(a));memset(b,0,sizeof(b));len1=strlen(cot1);len2=strlen(cot2);if(len1>len2)    l=len1;else    l=len2;for(i=0;i<l;i++){++a[cot1[i] - 'A'];++b[cot2[i] - 'A'];}sort(a,a+26);sort(b,b+26);for(i=0;i<26;i++)if(a[i] != b[i])   break;printf(i==26?"YES\n" : "NO\n");}return 0;} `

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.