String Task CodeForces - 118A

Text Reverse
Time limit 2000 ms
Memory limit 262144 kB
Source Codeforces Beta Round #89 (Div. 2)
Tags implementation strings *1100
Editorial Announcement Tutorial #1 Tutorial #2

Problem Description
Calculate A + B.

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
Input
tour
Output
.t.r
Input
Codeforces

Sample Output
.c.d.f.r.c.s
Input
aBAcAba
Output
.b.c.b

问题链接:CodeForces - 118A

问题简述:

输入测试字符串,在给定的字符串中(包括大写字母和小写拉丁字母),它:删除所有元音,插入一个字符“。在每个辅音之前,用相应的小写辅音替换所有大写辅音。元音是字母“A”、“O”、“Y”、“E”、“U”、“I”,其余都是辅音。以单个字符串的形式返回输出。

问题分析:
利用ASCII码大小写的数值差实现大小写转换

程序说明:
利用ASCII码大小写的数值差实现大小写转换,然后依靠条件判断删去元音字母。

 #include <iostream>
    using namespace std;
    
    int main()
    {
    	char p[101], a[201];
    	char *s = p;
    	cin >> p;
    	int j = 0;
    	for (int i = 0; *(s + i) != '\0'; i++)
    	{
    		if (*(s+i) >= 'A'&& *(s+i) <= 'Z')
    			*(s + i) += 32;
    		if (*(s + i) !='a' && *(s + i) != 'e' && *(s + i) != 'i' && *(s + i) != 'o' && *(s + i) != 'u' && *(s + i) != 'y')
    		{
    			a[j++] = '.';
    			a[j++] = s[i];
    		}
    	}
    	a[j] = '\0';
    	cout << a << endl;
    }
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值