1009 说反话 pat
来源:互联网 发布:生意宝,网络小贷牌照 编辑:程序博客网 时间:2024/05/06 19:59
#include<iostream>
#include <string>
#include <stack>
using namespace std;
string FanZhuan(string temp)
{
stack<string> stack;
stack.push("&&");
string str;
int fir = 0, sec = 0;
int i = 0;
while (true)
{
if ((temp[i] != ' ')&&temp[i] != 0)
{
i += 1;
continue;
}
else if(temp[i] == 0)
{
stack.push(temp.substr(fir,i));
break;
}
else
{
stack.push(temp.substr(fir, i-fir));
fir = i+1;
i += 1;
}
}
while (stack.top() != "&&")
{
str += stack.top();
str += " ";
stack.pop();
}
return str.substr(0,str.size()-1);
}
int main()
{
string temp;
getline(cin, temp);
cout<<FanZhuan(temp);
}
#include <string>
#include <stack>
using namespace std;
string FanZhuan(string temp)
{
stack<string> stack;
stack.push("&&");
string str;
int fir = 0, sec = 0;
int i = 0;
while (true)
{
if ((temp[i] != ' ')&&temp[i] != 0)
{
i += 1;
continue;
}
else if(temp[i] == 0)
{
stack.push(temp.substr(fir,i));
break;
}
else
{
stack.push(temp.substr(fir, i-fir));
fir = i+1;
i += 1;
}
}
while (stack.top() != "&&")
{
str += stack.top();
str += " ";
stack.pop();
}
return str.substr(0,str.size()-1);
}
int main()
{
string temp;
getline(cin, temp);
cout<<FanZhuan(temp);
}
0 0
- 1009 说反话 pat
- PAT 1009 说反话
- 1009 说反话 PAT
- PAT-1009 说反话
- 1009,说反话,PAT
- PAT 1009 说反话
- PAT 1009 说反话
- PAT 1009说反话
- PAT 1009 说反话
- PAT---1009说反话
- PAT basic 1009 : 说反话
- PAT乙级 1009 说反话
- PAT 乙级 1009 说反话
- PAT乙级1009 说反话
- PAT 1009 说反话 (20)
- PAT乙级1009: 说反话(20)
- PAT(basic level) 1009 说反话
- PAT-1009B 说反话 (20)
- 动画效果之渐变、缩放、平移、旋转<代码实现>
- Android之坐标系统
- shell中单中括号和双中括号的区别
- Linux文件系统
- Android Shape的使用
- 1009 说反话 pat
- 大学的目标与计划
- Web负载均衡的几种实现方式
- AMD中国研究院急聘实习生
- Android 文件的读取与写入
- Activity提取公因式
- android ViewPagerIndicator使用心得
- C# 委托与事件
- 阻塞(=)赋值和非阻塞(<=)赋值