codeforces 118A String Task
来源:互联网 发布:简明python教程豆瓣 编辑:程序博客网 时间:2024/05/17 20:27
Petya started to attend programming lessons. On the first lesson his task was to write a simple program. The program was supposed to do the following: in the given string, consisting if uppercase and lowercase Latin letters, it:
- deletes all the vowels,
- inserts a character "." before each consonant,
- replaces all uppercase consonants with corresponding lowercase ones.
Vowels are letters "A", "O", "Y", "E", "U", "I", and the rest are consonants. The program's input is exactly one string, it should return the output as a single string, resulting after the program's processing the initial string.
Help Petya cope with this easy task.
The first line represents input string of Petya's program. This string only consists of uppercase and lowercase Latin letters and its length is from1 to 100, inclusive.
Print the resulting string. It is guaranteed that this string is not empty.
tour
.t.r
Codeforces
.c.d.f.r.c.s
aBAcAba
.b.c.b
AC:
#include<bits/stdc++.h>
using namespace std;
int main()
{
string str;
int pos,len;
cin>>str;
len=str.length();
transform(str.begin(), str.end(), str.begin(), ::tolower);
for(int i=0;i<len;i++)
{
switch(str[i])
{
case 'a':str[i]=0;
case 'e':str[i]=0;
case 'i':str[i]=0;
case 'o':str[i]=0;
case 'u':str[i]=0;
case 'y':str[i]=0;
default:continue;
}
}
for(int i=0;i<len;i++)
if(str[i]!=0)
cout<<'.'<<str[i];
cout<<endl;
}
switch用法和string类的大小写转换
transform(str.begin(), str.end(), str.begin(), ::toupper); 转换为大写
transform(str.begin(), str.end(), str.begin(), ::tolower);转换为小写
- CodeForces 118A. String Task
- codeforces 118A String Task
- 【CodeForces】A. String Task
- Problem--118A--Codeforces--String Task
- CodeForces 118 A.String Task(水~)
- codeforces 118A String Task(字符串水题)
- 118A - String Task
- 118A String Task
- CF - 118A - String Task
- CF: 118A.String Task
- CF 118A string task
- Codeforces Beta Round #89 (Div. 2) / 118A String Task(字符串操作)
- A. String Task
- 【CODEFORCES】 A. Appleman and Easy Task
- codeforces 558 E A Simple Task
- 【30.93%】【codeforces 558E】A Simple Task
- codeforces 462A Appleman and Easy Task
- 【简单过滤】#89 A. String Task
- C++高级编程 第十三章: 有效的内存管理
- 位运算
- iOS老铁,是时候干掉 iOS8 了!
- Java集合之ConcurrentHashMap源码浅析
- 贪心算法-4.6.1最小生成树之Prim算法(切分定理)
- codeforces 118A String Task
- 利用caffe的Python接口生成prototxt文件
- KVM虚拟机启动和异常处理示意图
- Galaxy S8及S+全屏显示适配
- 集合
- Android多渠道SDK开发心得(1)——最简单的aar包sdk
- 利用itext操作pdf从数据库导出大量数据--创建PDF相关(二)
- BZOJ 2178: 圆的面积并 simpson积分
- Bitmap oom