第一题、
题解:
#include<iostream>
#include<string>
using namespace std;
int main()
{
string str;
cin >> str;
bool flag=false;
for (int i = 0; i < str.size(); i++)
{
int mark = 0;
for (int j = 0; j < str.size(); j++)
{
if (str[j] == str[i])
{
mark++;
}
}
if (mark == 1)
{
cout << str[i] << endl;
flag=true;
break;
}
}
if (!flag)
{
cout << "no" << endl;
}
return 0;
}
第二题、
题解:
#include<iostream>
#include<string>
using namespace std;
int main()
{
double num1,num2=0;
string str1, str2;
cin >> num1 >> str1 >> str2;
for (int i = 0; i < str1.size(); i++)
{
if (str1[i] == str2[i])
{
num2++;
}
}
num2 = num2 / str1.size();
if (num2 > num1)
cout << "yes" << endl;
else
cout << "no" << endl;
return 0;
}
#include<iostream>
#include<string>
using namespace std;
int main()
{
double num1,num2=0;
string str1 ;
cin >> num1>> str1;
for (int i = 0; i < str1.size(); i++)
{
char ch;
cin >> ch;
if (str1[i] == ch)
{
num2++;
}
}
num2 = num2 / str1.size();
if (num2 > num1)
cout << "yes" << endl;
else
cout << "no" << endl;
return 0;
}
第三题、
题解:
#include<iostream>
#include<string>
using namespace std;
int main()
{
int n, arr[100];
cin >> n;
string s1, s2;
for (int i = 0; i < n; i++)
{
cin >> s1 >> s2;
if (s1 == s2)
{
arr[i] = 0;
}
else if (s1 == "Rock" && s2 == "Scissors" || s1 == "Scissors" && s2 == "Paper"|| s1 == "Paper" && s2 == "Rock")
{
arr[i] = 1;
}
else if (s2 == "Rock" && s1 == "Scissors" || s2 == "Scissors" && s1 == "Paper" || s2 == "Paper" && s1 == "Rock")
{
arr[i] = 2;
}
}
for (int i = 0; i < n; i++)
{
if (arr[i] == 0) cout << "tie" << endl;
if (arr[i] == 1) cout << "player1" << endl;
if (arr[i] == 2) cout << "player2" << endl;
}
}