1. AcWing 763. 循环相克令( https://www.acwing.com/problem/content/765/ )
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
int t;
string ch1,ch2;
cin>>t;
while(t--){
cin>>ch1>>ch2;
if(ch1==ch2) cout<<"Tie"<<endl;
else{
if(ch1=="Hunter")
if(ch2=="Bear") cout<<"Player2"<<endl;
else cout<<"Player1"<<endl;
if(ch1=="Bear")
if(ch2=="Hunter") cout<<"Player1"<<endl;
else cout<<"Player2"<<endl;
if(ch1=="Gun")
if(ch2=="Hunter") cout<<"Player2"<<endl;
else cout<<"Player1"<<endl;
}
}
return 0;
}
#include<iostream>
#include<cstring>
using namespace std;
int get(string s)
{
if(s=="Hunter") return 0;
if(s=="Bear") return 1;
return 2;
}
int main()
{
int t;
string a,b;
cin>>t;
while(t--)
{
cin>>a>>b;
int x=get(a),y=get(b);
if(x==y) cout<<"Tie"<<endl;
else if((x+1)%3==y) cout<<"Player2"<<endl;
else cout<<"Player1"<<endl;
}
return 0;
}
啥也不说了,y总牛逼!!!
2. AcWing 756. 蛇形矩阵( https://www.acwing.com/problem/content/758/ )
3.
4. AcWing 764. 输出字符串( https://www.acwing.com/problem/content/766/ )
#include<iostream>
#include<string>
using namespace std;
int main()
{
string a,b;
getline(cin,a);
for(int i=0;i<a.size()-1;i++)
b+=a[i]+a[i+1];
b+=a[a.size()-1]+a[0];
cout<<b;
return 0;
}
#include<iostream>
#include<string>
using namespace std;
int main()
{
string a,b;
getline(cin,a);
int len=a.size();
for(int i=0;i<len;i++)
b+=a[i]+a[(i+1)%len];//b+=(char)(a[i]+a[(i+1)%len]);
cout<<b;
return 0;
}
5.AcWing 767. 信息加密( https://www.acwing.com/problem/content/description/769/ )
这个题思路不难,但就是看怎么做最快了
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
string str;
getline(cin,str);
for(int i=0;str[i];++i){
if(str[i]<='y'&&str[i]>='a'||str[i]>='A'&&str[i]<='Y')
str[i]++;
else if(str[i]=='z') str[i]='a';
else if(str[i]=='Z') str[i]='A';
}
cout<<str;
}
y总
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
string s;
getline(cin,s);
for(int i=0;s[i];++i)
if(s[i]<='z'&&s[i]>='a') s[i]=(s[i]-'a'+1)%26+'a';
else if(s[i]<='Z'&&s[i]>='A') s[i]=(s[i]-'A'+1)%26+'A';
cout<<s;
return 0;
}
不应该发在题解里面吗?
水题。。