蓝桥杯第五届省赛C/C++A组个人题解

版权声明:转载请注明出处https://blog.csdn.net/hhmy77 https://blog.csdn.net/hhmy77/article/details/88780519

猜年龄

答案 10

#include<bits/stdc++.h>
using namespace std;
int main()
{
	for(int i=1;i<100;i++)
	{
		for(int j=1;j<100;j++)
		{
			//j 是哥哥 i 是妹妹
			 
			if(i*j==6*(i+j)&&i<j)printf("%d %d\n",i,j);
		}
	}
}  

切面条 神奇算式 蚂蚁感冒 史丰收速算

https://blog.csdn.net/hhmy77/article/details/88778874 已经写了

扑克序列

全排列AA223344输出判断符合条件的结果
答案(这里偷懒用了next_permutation来输出全排列,事实上如果初始是AA223344的话AA是不会动的,所以我把A改成了1,答案如下就是2342A3A4

在这里插入图片描述

#include<bits/stdc++.h>
using namespace std;
string rst="11223344";
bool check()
{
	string str=rst;
	char book[]={'1','2','3','4'};
	int flag[4]={0};
	int dist[4]={0};
 	for(int i=0;i<4;i++)
	{
		for(int j=0;j<str.size();j++)
		{
			if(flag[i]==1)
			{
				if(str[j]==book[i])break;
				dist[i]++;
			}
			if(str[j]==book[i])
				flag[i]++;
		}
	}

	for(int i=0;i<4;i++)
	{
		if(dist[i]!=i+1)return false;
	}
	
	
	return true;
}
int main()
{
	do
	{
		if(check())
		{
			cout<<rst<<endl;	
		}
	}while(next_permutation(rst.begin(),rst.end()));
} 

斐波那契 波动数列 地宫取宝

看别人的吧 暂时不会写。。

猜你喜欢

转载自blog.csdn.net/hhmy77/article/details/88780519