概述
作为ACM小白一枚,参加了ACM爱好者协会的寒假集训。希望能够用博客记录每一天的生活和进步。
ACM之旅
第一天 基础知识讲解
博文目录
- 今日感想
- 题目C 元音字母 (唯一一道AC的题)
- 题目E 从因数中找出来两个数 (差一点就AC的)
今日感想
一下子就上手C++感觉很不适应,做了几道题只AC了一道,成绩很一般,落差很大。
下面是题目总结。
题目C 元音字母 (唯一一道AC的题)
题目描述
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 s can transform to another superhero with name t if s can be made equal to t by changing any vowel in s to any other vowel and any consonant in s 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 s can be transformed to the Superhero with name t.
输入
The first line contains the string s having length between 1 and 1000, inclusive.
The second line contains the string t having length between 1 and 1000, inclusive.
Both strings s and t are guaranteed to be different and consist of lowercase English letters only.
输出
Output “Yes” (without quotes) if the superhero with name s can be transformed to the superhero with name t and “No” (without quotes) otherwise.
You can print each letter in any case (upper or lower).
原思路
题目的意思就是元音和辅音相应位置是相对的。所以我建立了两个数组,然后我考虑,如果a这个是元音,那么b也是,否则退出,返回不是;如果a这个是辅音,b也必须不是元音,否则退出,返回不是;如果长度不等,直接退出,返回不是。
AC代码(写得不好,下面有改进代码)
#include <bits/stdc++.h>
using namespace std;
int main(){
char voewl[]={'a','e','i','o','u'};
char a[1001];
char b[1001];
int i=0;
int j;
int j_1;
int result=0;
int a_v=0;
scanf("%s",a);
scanf("%s",b);
while(a[i]!='