211203

//有5个人坐在一起,问第5个人多少岁?他说比第4个人大两岁。

//问第4个人岁数,他说比第3个人大两岁。

//问第3个人,又说比第2个人大两岁。

//问第2个人,说比第1个人大两岁。

//最后问第1个人,他说是10岁。

//请问第5个人多大?

# include <iostream>
using namespace std;
int age(int n)
{
	int c;
	if(n==1)
		c=10;
	else 
	{
		//c=10+(n-1)*2;
		c=age(n-1)+2;
	}
	return c;
		
}
int main ()
{
	int a;
	cin>>a;
	cout<<age(a)<<endl;
	return 0;
}

//用递归方法求n!

# include <iostream>
using namespace std;
int jiecheng(int n)
{
	int sum=1;
	if(n==0 || n==1)
		n=1;
	else
		sum=jiecheng(n-1)*n;
	return sum;
}
int main ()
{
	int n;
	cin>>n;
	cout<<jiecheng(n)<<endl;
	return 0;
}

//01美丽数字

# include <iostream>
using namespace std;
int quyu(int a)
{
	int b;
	while(a>=10)
	{
		if(a%10==6 || a/10==6)
		{
			return 6;
			break;
		}
		else
			a=a/10;
	}
	return 0;
}
int beau(int a)
{
	if(a%6==0)
	{	
		cout<<a<<endl;
		return 1;
	}
	else if(a>10 && quyu(a)==6)
	{
		cout<<a<<endl;
		return 1;
	}
	else return 0;
}
int main ()
{
	int a;
	int n=0;
	int b=1;
	cin>>a;
	while(b<=a)
	{
		n+=beau(b);
		b+=1;
	}
	cout<<n;
	return 0;
}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值