信息学奥赛一本通---第五章--- 数 组--- 1129-1148 (第三节)题解

注:此为c++代码

    虽然我的代码无注释,但如想复制,必须完全搞懂代码所对应的题!

Dev c++这东西点进来的都有吧,详情见我的另一篇文章。

正式进入题解部分:          (本人小白,大佬们请勿吐槽)

1129:

#include<bits/stdc++.h>
using namespace std;
char a[300];
int sum,len;
int main()
{ 
	gets(a);
	len=strlen(a);
	for(int i=0;i<=len-1;i++)
	{
		if(a[i]>=48&&a[i]<=57)
		{
			sum++;
		}
	}
	cout<<sum;
	return 0;
}

1130:

#include<bits/stdc++.h>
using namespace std;
char a[100001],b;
int len,sum;
int main()
{
	gets(a);
	len=strlen(a);
    for(int i=0;i<=len-1;i++)
    {
    	sum=0;
    	b=a[i];
    	for(int j=0;j<=len-1;j++)
    	{
    		if(b==a[j])
    		{
    			sum++;
    		}
    	}
    	if(sum>=2)
    	{
    	}
    	else if(sum==1)
    	{
    		cout<<b;
    		return 0;
    	}
    }
    cout<<"no";
    return 0;
}

1131:

#include<bits/stdc++.h>
using namespace std;
char a[501],b[501];
double len,sum,c;
int main()
{
	cin>>c>>a>>b;
	len=strlen(a);
    for(int i=0;i<=len-1;i++)
    {
    	if(a[i]==b[i])
    	{
    		sum++;
    	}
	}
	if(sum/len>=c)
	{
		cout<<"yes";
	}
	else
	{
		cout<<"no";
	}
    return 0;
}

1132:

#include<iostream>
using namespace std;
char a[101],b[101];
int n;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a>>b;
        if(a[0]=='R'&&b[0]=='S'||a[0]=='S'&&b[0]=='P'||a[0]=='P'&&b[0]=='R')
        {
        	cout<<"Player1"<<endl;
        }
        else if(a[0]==b[0])
        {
        	cout<<"Tie"<<endl;
        } 
        else
        {
        	cout<<"Player2"<<endl;
        } 
    }
    return 0;
}

1133:

#include<bits/stdc++.h>
using namespace std;
char ch[101];
int len;
int main()
{
    gets(ch);
    len=strlen(ch);
    for(int i=0;i<=len-2;i++)
    {
    	cout<<char(ch[i]+c
  • 5
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值