HDU 1048 The Hardest Problem Ever
2015-07-25 12:09
281 查看
题目地址:点击打开链接
思路:不用找规律,直接贴数组,数组开大点,否则会错
AC代码:
#include <iostream>
#include<cstring>
using namespace std;
int main()
{
int n,i;
char a[27] = "VWXYZABCDEFGHIJKLMNOPQRSTU";
char cipher[1000];
while(cin.getline(cipher,1000))
{
if(strcmp(cipher,"ENDOFINPUT") == 0)
break;
if(strcmp(cipher,"START") != 0 && strcmp(cipher,"END") != 0)
{
n = strlen(cipher);
for(i=0; i<n; i++)
{
if(cipher[i] >= 'A' && cipher[i] <= 'Z')
{
cout<<a[cipher[i] - 'A'];
}
else
cout<<cipher[i];
}
cout<<endl;
}
}
return 0;
}
思路:不用找规律,直接贴数组,数组开大点,否则会错
AC代码:
#include <iostream>
#include<cstring>
using namespace std;
int main()
{
int n,i;
char a[27] = "VWXYZABCDEFGHIJKLMNOPQRSTU";
char cipher[1000];
while(cin.getline(cipher,1000))
{
if(strcmp(cipher,"ENDOFINPUT") == 0)
break;
if(strcmp(cipher,"START") != 0 && strcmp(cipher,"END") != 0)
{
n = strlen(cipher);
for(i=0; i<n; i++)
{
if(cipher[i] >= 'A' && cipher[i] <= 'Z')
{
cout<<a[cipher[i] - 'A'];
}
else
cout<<cipher[i];
}
cout<<endl;
}
}
return 0;
}
相关文章推荐
- android SDK问题
- IRC相关频道
- 黑马程序员——集合框架(泛型限定)
- VS2013 API方法连接 64位 MySQL56
- RMQ问题--ST算法(Sparse Table)
- C#中对泛型List进行分组输出元素
- [POJ 1832] 连环锁 格雷码
- 线程的同步异步,以及具体代码实现,使用场景
- 2张图片叠放,根据鼠标的移动来显示
- [CareerCup] 3.1 Implement Three Stacks using Array 使用数组来实现三个栈
- 灵活运用的技术已实现
- 常用npm & gem 汇总
- Entity Framework
- hdoj 1286 找新朋友(求欧拉函数)
- 批处理设置系统环境变量
- Openssl gendsa命令
- 《跆拳道特技教程》
- linux 查看系统信息命令
- PDU短信发送之五
- Ruby 中的类和对象