PAT 天梯赛模拟. 成都信息工程大学天梯赛模拟(待更新)
原题链接
简单
作者:
bukki
,
2024-03-17 23:40:29
,
所有人可见
,
阅读 16
记住这次血的教训,忘记清空数组了,自己想的样例居然没一个发觉这个问题,最后一分没有 哈哈哈
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <stack>
using namespace std;
int main(){
int n;
cin>>n;
stack<int> st;
vector<int> m,k;
while(n--){
int x;
cin>>x;
while(x){
st.push(x%10);//st存翻转之后的数
k.push_back(x%10);//k用vector存原来的数
x/=10;
}
while(!st.empty()){
int t=st.top();
m.push_back(t);//m用vector存翻转后的数
st.pop();
}
if(k==m) cout<<"true"<<endl;
else cout<<"false"<<endl;
//清空数组!!!!!!!
k.clear();
m.clear();
}
return 0;
}