1. 程式人生 > >CodeCraft-19 and Codeforces Round #537 (Div. 2) A - Superhero Transformation

CodeCraft-19 and Codeforces Round #537 (Div. 2) A - Superhero Transformation

cer ase multipl 末尾 prev diff math term flag

題目描述

We all know that a superhero can transform to certain other superheroes. But not all Superheroes can transform to any other superhero. A superhero with name ss can transform to another superhero with name tt if ss can be made equal to tt by changing any vowel in ss to any other vowel and any consonant in

ss to any other consonant. Multiple changes can be made.

In this problem, we consider the letters ‘a‘, ‘e‘, ‘i‘, ‘o‘ and ‘u‘ to be vowels and all the other letters to be consonants.

Given the names of two superheroes, determine if the superhero with name ss can be transformed to the Superhero with name

tt.

Input

The first line contains the string ss having length between 11 and 10001000, inclusive.

The second line contains the string tt having length between 11 and 10001000, inclusive.

Both strings ss and tt are guaranteed to be different and consist of lowercase English letters only.

Output

Output "Yes" (without quotes) if the superhero with name

ss can be transformed to the superhero with name tt and "No" (without quotes) otherwise.

You can print each letter in any case (upper or lower).

Examples input
a
u
output
Yes
input
abc
ukm
output
Yes
input
akm
ua
output
No
Note

In the first sample, since both ‘a‘ and ‘u‘ are vowels, it is possible to convert string ss to tt.

In the third sample, ‘k‘ is a consonant, whereas ‘a‘ is a vowel, so it is not possible to convert string ss to tt.

思路:簽到題,就是元音和輔音相同位置的相同的話,輸出Yes,不同的話輸出No;

註意

strlen()函數求出的字符串長度為有效長度,既不包含字符串末尾結束符 ‘\0’;
sizeof()操作符求出的長度包含字符串末尾的結束符 ‘\0’;
當在函數內部使用sizeof()求解由函數的形參傳入的字符數組的長度時,得到的結果為指針的長度,既對應變量的字節數,而不是字符串的長度,此處一定要小心。

代碼如下:

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 #define ll long long
 4 
 5 int vow(char a,char b)
 6 {
 7     if(a == b)
 8     return 1;
 9     else if(a == a || a == o || a == e || a == i || a == u)
10     {
11         if(b == a || b == o || b == e || b == i || b == u)//元元
12         return 1;
13         else//元輔
14         return 0;
15     }
16     else if(b == a || b == o || b == e || b == i || b == u)//輔元
17     return 0;
18     //輔輔
19     return 1;
20 }
21 int main()
22 {
23     string s,t;
24     while(cin >> s >> t)
25     {
26         int sl = s.size();
27         int tl = t.size();
28         if(sl != tl)
29         {
30             cout << "No" << endl;
31             continue;
32         }
33         bool flag = 0;
34         for(int i = 0;i < sl;i++)
35         {
36             if(vow(s[i],t[i]) == 0)
37             {
38                 cout << "No" << endl;
39                 flag = 1;
40                 break;
41             }
42         }
43         if(flag == 0)
44         cout << "Yes" << endl;
45     }
46     return 0;
47 }

CodeCraft-19 and Codeforces Round #537 (Div. 2) A - Superhero Transformation