반응형

A. String Task

time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

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

 

<처음에 푼 방법>

#include<stdio.h>
#include<string.h>

int main()
{
	char arr[101];
	
	scanf("%s", &arr);

	int len = strlen(arr);

	for (int i = 0; i < len; i++)
	{
		if (arr[i] < 91)
		{
			arr[i] += 32;
		}
	}
	for (int i = 0; i < len; i++)
	{
		if (arr[i] == 'a' || arr[i] == 'o' || arr[i] == 'y' || arr[i] == 'e' || arr[i] == 'u' || arr[i] == 'i')
		{
			
		}
		else
		{
			printf(".%c", arr[i]);
		}
	}
	
	

	return 0;
}



 

 

<tolower, toupper 함수를 이용한 방법>

#include<stdio.h>
#include<string.h>
#include <ctype.h>

int main()
{
	char arr[101];
	
	scanf("%s", &arr);

	int len = strlen(arr);

	for (int i = 0; i < len; i++)
	{
		if    (tolower(arr[i]) == 'a' 
			|| tolower(arr[i]) == 'o' 
			|| tolower(arr[i]) == 'y' 
			|| tolower(arr[i]) == 'e' 
			|| tolower(arr[i]) == 'u' 
			|| tolower(arr[i]) == 'i')
		{
			
		}
		else
		{
			printf(".%c", tolower(arr[i]));
		}
	}
	
	

	return 0;
}



 

tolower(), toupper() 함수

 

int tolower(int c); 문자를 소문자로 변환

int toupper(int c); 문자를 대문자로 변환

입력 매개 변수 리스트

c 아스키 코드 값 (ex : 'A'라는 문자는 아스키 코드 값으로는 65 이다.)

반환 값

tolower 함수는 문자가 대문자일 때 소문자 반환

toupper 함수는 문자가 소문자일 때 대문자 반환

#include<stdio.h>
#include<string.h>
#include<ctype.h>

int main()
{
	char arr[101];
	int i = 0;
	
	scanf("%[^\n]", &arr); // 엔터를 제외한 모든 문자열을 다 받음!

	int l = strlen(arr);
	
	for (int j = 0; j < l; j++)
	{
		if (isupper(arr[i]))
		{
			printf("%c", tolower(arr[i]));
		}
		else if (islower(arr[i]))
		{
			printf("%c", toupper(arr[i]));
		}
		else if (arr[i] == ' ')
		{
			printf(" ");
		}

		i++;
	}

	return 0;
}



scanf("%[^\n]", &arr); // 엔터를 제외한 모든 문자열을 다 받음!

 

http://codeforces.com/problemset/problem/118/A

 

Problem - 118A - Codeforces

 

codeforces.com

 

 

 

 

 

반응형

'🧩PS > 🥈Nomal' 카테고리의 다른 글

[C/C++] Codeforce 734B - Anton and Digits  (0) 2020.04.04
[C/C++] Codeforce 1285B - Just Eat It!  (0) 2020.04.04
[C/C++] Codeforce 71A - Way Too Long Words  (0) 2020.03.22
[C/C++] Codeforce 4A - Watermelon  (0) 2020.03.22
[PYTHON] 중간수  (0) 2020.03.04

+ Recent posts