acm第一题

Time limit2000 msMemory limit262144 kBSourceCodeforces Beta Round #89 (Div. 2)Tagsimplementation strings *1100EditorialAnnouncement Tutorial #1 Tutorial #2

problem description

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.

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.

Example Input
tour
Example Output
.t.r
Example input
Codeforces
Example Output
.c.d.f.r.c.s
Example input
bcAba
Example Output
.b.c.b

问题连接 https://vjudge.net/problem/CodeForces-118A

问题描述:输入一串字符,将元音字母除去,在辅音字母前加. ,将大写字母改成小写字母。

问题分析:将写进的字母组成一个字符串数组,利用处理数组的方法进行处理

程序说明:用strlen函数得到输入的字符数,进行相对应的操作

c++程序如下:

#include<iostream>
using namespace std;
int main()
{   char a[50];
	    cin>>a;
		int n = strlen(a);
        for(int i=0;i<n;i++)
    {if(a[i]=='a'||a[i]=='A'||a[i]=='e'||a[i]=='E'||a[i]=='i'||a[i]=='I'||a[i]=='o'||a[i]=='O'||a[i]=='u'||a[i]=='U'||a[i]=='y'||a[i]=='Y')
		{}
	else {if('A'<a[i]&&a[i]<'Z')  {  a[i]+=32; cout<<'.'<<a[i];}
	      else  cout<<'.'<<a[i];
          }
    }
}

猜你喜欢

转载自blog.csdn.net/weixin_44009750/article/details/84875449