HDOJ  2562   奇偶位互换
2015-12-18 18:08
274 查看
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2562
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int T;
char
temp;
string
s;
cin>>T;
while(T--)
{
cin>>s;
for(int i=0;i<s.length();i+=2)
{
temp=s[i+1];
s[i+1]=s[i];
s[i]=temp;
}
cout<<s<<endl;
}
return
0;
}
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int T;
char
temp;
string
s;
cin>>T;
while(T--)
{
cin>>s;
for(int i=0;i<s.length();i+=2)
{
temp=s[i+1];
s[i+1]=s[i];
s[i]=temp;
}
cout<<s<<endl;
}
return
0;
}
相关文章推荐
- HDOJ&nbsp;&nbsp;&nbsp;2561&nbsp;&nbsp;&nbsp;第二小整数
- HDOJ&nbsp;&nbsp;&nbsp;2551&nbsp;&nbsp;&nbsp;竹青遍野
- HDOJ&nbsp;&nbsp;2550&nbsp;&nbsp;&nbsp;百步穿杨
- HDOJ&nbsp;&nbsp;2549&nbsp;&nbsp;&nbsp;&nbsp;壮志难酬
- 安装时防火墙未关闭报错
- 数据分析师考试和scanf读取数据的问题
- C++处理异常技巧-try,catch,throw,finally
- Android网络连接判断与处理
- java提高篇(二三)-----HashMap
- HDOJ&nbsp;&nbsp;2548&nbsp;&nbsp;&nbsp;两军交锋
- HDOJ&nbsp;&nbsp;2500&nbsp;&nbsp;&nbsp;做一个正气的杭电人
- HDOJ&nbsp;1847&nbsp;&nbsp;&nbsp;Good&nbsp;Luck&nbsp;in&nbsp;CET-4&nbsp;E…
- HDOJ&nbsp;&nbsp;1846&nbsp;&nbsp;&nbsp;Brave&nbsp;Game
- HDOJ&nbsp;1028&nbsp;&nbsp;&nbsp;Ignatius&nbsp;and&nbsp;the&nbsp;Pri…
- 整数拆分问题
- HDOJ&nbsp;&nbsp;&nbsp;2081&nbsp;&nbsp;&nbsp;手机短号
- HDOJ&nbsp;&nbsp;&nbsp;2072&nbsp;&nbsp;&nbsp;单词数
- HDOJ&nbsp;&nbsp;2025&nbsp;&nbsp;&nbsp;查找最大元素
- HDOJ&nbsp;&nbsp;2024&nbsp;&nbsp;&nbsp;&nbsp;C语言合法标识符
- HDOJ&nbsp;&nbsp;2016&nbsp;&nbsp;&nbsp;数据的交换输出