2014
01-04

Encoding The Diary

You know many girls likes writing diaries,of course they have some secrets don’t want others to know.So this time, they asked you to encoding the diary.
The rule is :
Give you a string. Such as “ARE YOU AC?”
Firstly , delete all spaces in this string.
You will get “AREYOUAC?”
String AREYOUAC?
Index 123456789
Secondly,print the characters who’s index are the multiple of 3.
Thirdly, print the characters who’s index are the multiple of 2.If it has been printed,just ignore it .
At last,print the characters that have not been printed.

Each case will contain a string in one line.You may suppose the length of the string will not exceed 200.

Each case will contain a string in one line.You may suppose the length of the string will not exceed 200.

ARE YOU AC?

EU?RYCAOA

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <stdlib.h>
using namespace std;

int main()
{
char str[500],s[500];
int hash[500];
int i,len,l;
while(gets(s))
{
l = 1;
len = strlen(s);
memset(hash,0,sizeof(hash));
for(i = 0;i<len;i++)
{
if(s[i]==' ')
continue;
str[l] = s[i];
hash[l++] = 1;
}
for(i = 3;i<l;i+=3)
{
printf("%c",str[i]);
hash[i] = 0;
}
for(i = 2;i<l;i+=2)
{
if(hash[i] == 0)
continue;
printf("%c",str[i]);
hash[i] = 0;
}
for(i = 1;i<l;i++)
{
if(hash[i] == 0)
continue;
printf("%c",str[i]);
}
printf("\n");
}

return 0;
}