#89 A

It seems the problem is easy. Using 2 arrays, one to hold the original input string, and copy chars to the other according to the rules.
In order to make code more tidy, I don't do all the thing within a single loop, instead, I will do the upper to lower work in the first loop, here I like the trick between lower and upper.
upper + 32 == lower. and since the 26 letters are biger than 64, so upper | 32 = lower and most importantly
lower |= 32  == lower, good.
Another reason to do this first is that I don't want to write a long if condition expression because vowels could be upper.

Compile Error , in G++, iostream.h doesn't include stdio.h ?
Compile Error again, using strlen without string.h.

Accepted.

#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

#define MAX 200

char a1[MAX] = { 0 }, a2[MAX] = { 0 };

int main() {
scanf("%s", a1);
int len = strlen(a1);
int i,j;
for( i=0;i<len;i++ )
a1[i] |= 32;

for( i=0,j=0;i<len;i++ ) {
if( a1[i] == 'o' || a1[i] == 'a' || a1[i] == 'u' || a1[i] == 'i' || a1[i] == 'e' || a1[i] == 'y' )
continue;

a2[j++] = '.';
a2[j++] = a1[i];
}

printf("%s\n", a2);
return 0;
}



转载于:https://www.cnblogs.com/klzwj1988/archive/2011/10/09/2203337.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值