第一题

String Task

Time limit 2000ms
Memory limit 262144kb

Problem Description

Petya need to write a program which was supposed to do the following: in the given string, consisting if uppercase and lowercase Latin letters, it:
1.deletes all the vowels,
2.inserts a character “.” before each consonant,
3.replaces all uppercase consonants with corresponding lowercase ones.
Vowels are letters “A”, “O”, “Y”, “E”, “U”, “I”, and the rest are consonants.

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

Codeforces

Sample Output

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

第一题

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

问题简述:

输入大小写字母进行以下处理

  1. 删除所有元音字母
  2. 在辅音字母前插入字符“.”
  3. 将大写辅音字母转化为小写辅音字母

问题分析:

利用循环先筛掉元音字母,再将大写辅音字母转化为小写辅音字母,再通过循环找到辅音字母利用两次的输出先输出“.”再输出小写辅音字母

程序说明:

用scanf对letter数组进行输入字符串,用strlen计算出输入的长度,用for循环语句和if筛掉大小写的元音字母并改写为‘0’,再通过for循环语句通过大小写相差32将大写转换为小写,最后再通过for循环语句找到之前改写的‘0’输出‘.’和字母

AC通过的C语言程序如下:

#include <iostream>



int main()
{
	int length;
	char letter[1000];
	scanf("%s", letter);
	length = strlen(letter);
	
	for (int i = 0;i < length;i++)                                  //删掉元音字母
	{
		if (letter[i] == 'a' || letter[i] == 'o' || letter[i] == 'y'
		 || letter[i] == 'e' || letter[i] == 'u' || letter[i] == 'i'
		 ||letter[i] == 'A' || letter[i] == 'O' || letter[i] == 'Y' 
		 || letter[i] == 'E' || letter[i] == 'U' || letter[i] == 'I')
		{
			letter[i] = '0';
		}
	}
	
	for (int i = 0;i < length;i++)                                  //大写换小写
	{
		if ((letter[i] >= 'A') && (letter[i] <= 'Z'))
		{
			letter[i] = letter[i] + 32;
		}
	}
	for (int i = 0;i < length;i++)                                 //输出“.”和字母
	{
		if (letter[i]!='0')
		{
			printf(".");
			printf("%c", letter[i]);
		}
	}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值