C++#include<bits/stdc++.h>
using namespace std;
void solve()
{
string s;
cin>>s;
if(s.size()<3)
{
cout<<"No\n";
return ;
}
int sum=0;
for(int i=1; i<s.size()-2; i++)//要从1开始,到s.size()-2结束
{
string t=s.substr(0,i+1);
string r=t;
reverse(t.begin(),t.end());
string t1=s.substr(i+1);
string r1=t1;
reverse(t1.begin(),t1.end());
if(t==r&&t1==r1)
{
cout<<"Yes\n";
return ;
}
}
cout<<"No\n";
}
int main()
{
int n;
cin>>n;
while(n--)solve();
return 0;
}
C++B4260
#include <bits/stdc++.h>
using namespace std;
int month[13]= {0,31,28,31,30,31,30,31,31,30,31,30,31};
int main()
{
int y,m,d,h,k;
cin>>y>>m>>d>>h>>k;
h+=k;
if(h>=24)
{
h-=24;
d++;
}
if(y%4==0 && y%100!=0 || y%400==0)//此处为&&||
{
month[2]=29;
}
if(d>month[m])
{
d=1;
m++;
}
if(m>12)
{
m=1;
y++;
}
cout<<y<<' '<<m<<' '<<d<<' '<<h;
return 0;
}
C++#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
string s;cin>>s;//字符串如此输入
stack<ll>stk;
ll sum=0;//sum在这里定义
for(int i=0; i<s.size(); i++)//字符串从0开始遍历
{
if(isdigit(s[i]))
{
sum=sum*10+s[i]-'0';//不要忘-0
}
else if(s[i]=='.')
stk.push(sum),sum=0;
else if(s[i]=='+')
{
ll a=stk.top();stk.pop();
ll b=stk.top();stk.pop();
stk.push(a+b);
}
else if(s[i]=='-')
{
ll a=stk.top();stk.pop();
ll b=stk.top();stk.pop();
stk.push(b-a);
}
else if(s[i]=='*')
{
ll a=stk.top();stk.pop();
ll b=stk.top();stk.pop();
stk.push(a*b);
}
else if(s[i]=='/')
{
ll a=stk.top();stk.pop();
ll b=stk.top();stk.pop();
stk.push(b/a);
}
}
cout<<stk.top();
return 0;
}