• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
若忆_star
博客园    首页    新随笔    联系   管理    订阅  订阅
poj 1298 The Hardest Problem Ever

题目链接:http://poj.org/problem?id=1298

题目大意:按照所给的顺序要求将输入的字符串进行排列。

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cstring>
 4 using namespace std;
 5 int main ()
 6 {
 7     char str[27]= {"VWXYZABCDEFGHIJKLMNOPQRSTU"};
 8     char ch[100];
 9 
10     while (1)
11     {
12         gets(ch);
13         if (strcmp(ch,"START")==0)//strcmp是字符的一个函数,也就是两者之间的比较
14             continue;
15         else if (strcmp(ch,"END")==0)
16             continue;
17         else if (strcmp(ch,"ENDOFINPUT")==0)
18             break;
19         for (int i=0; ch[i]!='\0'; i++)
20         {
21             if (!(ch[i]>='A'&&ch[i]<='Z'))
22                 continue;
23             ch[i]=str[ch[i]-65];//运用ASCII进行字符之间的相互转换
24         }
25         puts(ch);
26     }
27     return 0;
28 }

 

posted on 2014-07-10 14:05  若忆_star  阅读(286)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3