HDU- 2265 Encoding The Diary

                        Encoding The Diary

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1289    Accepted Submission(s): 757


Problem Description
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.
 

 

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

 

Output
For each case, output the encoded string in one line.
 

 

Sample Input
ARE YOU AC?
 

 

Sample Output
EU?RYCAOA
 1 #include<stdio.h>
 2 #include<string.h>
 3 int main()
 4 { 
 5     char str1[200],str2[200];
 6     int i,k;
 7     while(gets(str1))
 8     {
 9              k=1;
10          for(i=0;str1[i]!='\0';i++)
11         {
12             if(str1[i]!=' ')
13                str2[k++]=str1[i];
14         }
15         str2[k]='\0';
16     
17      for(i=1;i<k;i++)
18     {
19         if(i%3==0)
20         {
21             printf("%c",str2[i]);
22             str2[i]='0';
23         }
24     }
25     for(i=1;i<k;i++)
26     {
27         if(i%2==0&&str2[i]!='0')
28         {
29             printf("%c",str2[i]);
30             str2[i]='0';
31         }
32     }
33     for(i=1;i<k;i++)
34         if(str2[i]!='0')
35            printf("%c",str2[i]);
36      printf("\n");
37     }
38     return 0;
39 }
40           
41   

 

 

转载于:https://www.cnblogs.com/cancangood/p/3407398.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值