#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;
}



posted @ 2011-10-09 10:11  DOF_KL  阅读(339)  评论(0编辑  收藏  举报