每日一题(8)

第一题、

题解:

#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;
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值