Text Reverse
Time limit 2000 ms
Memory limit 262144 kB
Source Codeforces Beta Round #89 (Div. 2)
Tags implementation strings *1100
Editorial Announcement Tutorial #1 Tutorial #2
Problem Description
Calculate A + B.
Input
The first line represents input string of Petya’s program. This string only consists of uppercase and lowercase Latin letters and its length is from 1 to 100, inclusive.
Output
Print the resulting string. It is guaranteed that this string is not empty.
Sample Input
Input
tour
Output
.t.r
Input
Codeforces
Sample Output
.c.d.f.r.c.s
Input
aBAcAba
Output
.b.c.b
问题链接:CodeForces - 118A
问题简述:
输入测试字符串,在给定的字符串中(包括大写字母和小写拉丁字母),它:删除所有元音,插入一个字符“。在每个辅音之前,用相应的小写辅音替换所有大写辅音。元音是字母“A”、“O”、“Y”、“E”、“U”、“I”,其余都是辅音。以单个字符串的形式返回输出。
问题分析:
利用ASCII码大小写的数值差实现大小写转换
程序说明:
利用ASCII码大小写的数值差实现大小写转换,然后依靠条件判断删去元音字母。
#include <iostream>
using namespace std;
int main()
{
char p[101], a[201];
char *s = p;
cin >> p;
int j = 0;
for (int i = 0; *(s + i) != '\0'; i++)
{
if (*(s+i) >= 'A'&& *(s+i) <= 'Z')
*(s + i) += 32;
if (*(s + i) !='a' && *(s + i) != 'e' && *(s + i) != 'i' && *(s + i) != 'o' && *(s + i) != 'u' && *(s + i) != 'y')
{
a[j++] = '.';
a[j++] = s[i];
}
}
a[j] = '\0';
cout << a << endl;
}