TTS

1--20--handsome no friend

这类的好多内容不允许有重复的。就用set比较省事。

#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<cmath>
#include <iostream>
#include <math.h>
#include <set>
using namespace std;
int main()
{
	int num;
	int n;
	cin>>n;
	set<string>s,ans;
	string str;
	while(n--)
	{
	
		cin>>num;
		if(num>=2)
		{
			while(num--)
			{
				cin>>str;
				s.insert(str);
			}
		}
		else
			cin>>str;
	}
	int m;
	cin>>m;
	int flag=0;
	while(m--)
	{
		cin>>str;
		//原始的set和存结果的set都要遍历一遍
		if(s.find(str)==s.end()&&ans.find(str)==ans.end())
		{
			ans.insert(str);
			//输出空格
			if(flag==1)
				cout<<" ";
			cout<<str;
			flag=1;
		}
	}
	if(flag==0)
		cout<<"No one is handsome";
	return 0;
}

zheng INT A+B

这个题坑好多啊。好多小细节。wa了好几次。

#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<cmath>
#include <iostream>
#include <math.h>
#include <set>
using namespace std;
int change(char *s)
{
	int ans=0;
	int len=strlen(s);
	for(int i=0;i<len;i++)
	{
	//	cout<<"s[i]"<<s[i]<<endl;
		ans+=((s[i]-'0')*pow(10,(len-i-1)));
	
	//	cout<<"ans "<<ans<<endl;
	}
	return ans;
}
int main()
{
	char a[10010],b[10010];
	scanf("%s ",a);
	gets(b);
	int flag1=0,flag2=0;
	for(int i=0;a[i];i++)
	{
		if(a[i]<48||a[i]>57)
		{
			flag1=1;
			break;
		}
	}
	for(int i=0;b[i];i++)
	{
		if(b[i]<48||b[i]>57)
		{
			flag2=1;
			break;
		}
	}
	if(flag1==0&&flag2==0)
	{
		int num1=change(a);
		int num2=change(b);
		if((num1>1000||num1<=0)&&(num2>=1&&num2<=1000))
		{
			cout<<"? + "<<b<<" = ?"<<endl;
			return 0;
		}
		else if((num2>1000||num2<=0)&&(num1>=1&&num1<=1000))
		{
			cout<<a<<" + ? = ?"<<endl;
			return 0;
		}
		else if((num1>1000||num1<=0)&&(num2>1000||num2<=0))
		{
			cout<<"? + ? = ?"<<endl;
			return 0;
		}
		int res=num1+num2;
		cout<<a<<" + "<<b<<" = "<<res<<endl;
	}
	else{
		if(flag1==0)
		{
			cout<<a<<" + ? = ?"<<endl;
		}
		else if(flag2==0)
		{
			cout<<"? + "<<b<<" = ?"<<endl;
		}
		else
			cout<<"? + ? = ?"<<endl;
	}
	return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值