2776. String Task

  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.

Examples

Input

  tour

Output

  .t.r

Input

  Codeforces

Output

  .c.d.f.r.c.s

Input

  aBAcAba

Output

  .b.c.b


说明:输入一个字符串,将这些字母(不论大小写)从字符串中删除:"A", "O", "Y", "E", "U", "I",然后此字符串的其他字符前添加一个小数点,输出的字符串都是小写。总体的想法:先转小写,然后删除指定字符,然后添加小数点,最后输出。

import java.util.Scanner;

public class Test2776 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine().toLowerCase();
        char[] chArr = str.toCharArray();
        String vowels = "aeyiou";

        // 删除元音字母(我又何必傻傻的真删除这个字符呢,不如将该字符设置为其他值,在拼接的时候,判断一下就行)
        for (int i = 0; i < chArr.length; i++) {
            if (vowels.indexOf(chArr[i]) != -1) {
                chArr[i]=‘1‘;
            }
        }

        str = "";

        // 在辅音字母前添加小数点
        for (int i = 0; i < chArr.length; i++) {
            if(chArr[i]!=‘1‘){
                str += "." + chArr[i];
            }
        }
        System.out.println(str);
        sc.close();
    }
}

原文地址:https://www.cnblogs.com/tangxlblog/p/9973758.html

时间: 2024-07-30 14:10:08

2776. String Task的相关文章

codeforces水题100道 第二十二题 Codeforces Beta Round #89 (Div. 2) A. String Task (strings)

题目链接:http://www.codeforces.com/problemset/problem/118/A题意:字符串转换……C++代码: #include <string> #include <iostream> using namespace std; string s; bool _in(char c, string s) { for (int i =0 ; i < s.length(); i ++) if (c == s[i]) return true; retu

Codeforces 118A String Task

题目链接 http://codeforces.com/problemset/problem/118/A #include<iostream> #include<string> #include<cctype> #include<algorithm> using namespace std; int main() { string str; cin>>str; int i; //将代码变成小写 transform(str.begin(), str.

C#多线程编程のTask(任务)

Task是.NET4.5加入的,跟线程池ThreadPool的功能类似,用Task开启新任务时,会从线程池中调用线程,而Thread每次实例化都会创建一个新的线程. 长耗时操作是不是常用 await Task.Run( )? 看下面代码: namespace WpfApplication6 { /// <summary> /// MainWindow.xaml 的交互逻辑 /// </summary> public partial class MainWindow : Window

(Task)任务异步(TAP)的使用

任务有返回值例子: 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 8 namespace Demo 9 { 10 class Program 11 { 12 13 static void Main(string[] args) 14 { 15 16 System.Threading.T

C#中 Thread,Task,Async/Await,IAsyncResult 的那些事儿!

说起异步,Thread,Task,async/await,IAsyncResult 这些东西肯定是绕不开的,今天就来依次聊聊他们 1.线程(Thread) 多线程的意义在于一个应用程序中,有多个执行部分可以同时执行:对于比较耗时的操作(例如io,数据库操作),或者等待响应(如WCF通信)的操作,可以单独开启后台线程来执行,这样主线程就不会阻塞,可以继续往下执行:等到后台线程执行完毕,再通知主线程,然后做出对应操作! 在C#中开启新线程比较简单 static void Main(string[]

.Net4.0 任务(Task)[转]

.Net4.0 任务(Task) 任务(Task)是一个管理并行工作单元的轻量级对象.它通过使用CLR的线程池来避免启动专用线程,可以更有效率的利用线程池.System.Threading.Tasks 命名空间下任务相关类一览: 类 作用 Task 管理工作单元 Task<TResult> 管理带返回值的工作单元 TaskFactory 创建任务 TaskFactory<TResult> 创建任务或者有相同返回值的延续任务 TaskScheduler 管理任务调度 TaskComp

.Net4.0 任务(Task)

.Net4.0 任务(Task),.net4.0任务task 任务(Task)是一个管理并行工作单元的轻量级对象.它通过使用CLR的线程池来避免启动专用线程,可以更有效率的利用线程池.System.Threading.Tasks 命名空间下任务相关类一览: 类 作用 Task 管理工作单元 Task<TResult> 管理带返回值的工作单元 TaskFactory 创建任务 TaskFactory<TResult> 创建任务或者有相同返回值的延续任务 TaskScheduler 管

认识Task和Task的基本使用(转)

对于多线程,我们经常使用的是Thread.在我们了解Task之前,如果我们要使用多核的功能可能就会自己来开线程,然而这种线程模型在.net 4.0之后被一种称为基于"任务的编程模型"所冲击,因为task会比thread具有更小的性能开销,不过大家肯定会有疑惑,任务和线程到底有什么区别呢?  任务和线程的区别: 1.任务是架构在线程之上的,也就是说任务最终还是要抛给线程去执行. 2.任务跟线程不是一对一的关系,比如开10个任务并不是说会开10个线程,这一点任务有点类似线程池,但是任务相比

Task Parallel Library02,更进一步

在前一篇中,了解了Task的基本用法 如果一个方法返回Task,Task<T>,如何获取Task的返回值,获取值的过程会阻塞线程吗? static void Main(string[] args) { var result = DoWorkAsync().Result; Console.WriteLine(result); Console.WriteLine("我会什么时候显示"); Console.ReadKey(); } static Task<string>