while循环

 1244-请问一个正整数能够整除几次2

#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int sum =0;
    while(n%2==0)
    {  
    	sum++;
        n=n/2;	
	}
	cout<<sum<<endl;
	return 0;
}

1062-求落地次数 

#include<iostream>
using namespace std;
int main()
{
    int n=100;
    int sum =0;
    while(n>=0.5)
    {   
        n=n/2;
    	sum++;

	}
	cout<<sum<<endl;
	return 0;
}

 1254-求车速

#include<iostream>
using namespace std;
int main()
{
    int n=95859;
    int n1=95895;
    while(true)
    {
    	n++;
	    int z=n%10;
		int x=n/10000%10;
		int c=n/1000%10;
		int v=n/10%10; 
	    if(x==z&&c==v)
	    {
	    	break;
		}
	}
	cout<<n<<endl;
	cout<<(n-n1)/2<<endl;
	return 0;
}

1261-韩信点兵

#include<iostream>
using namespace std;
int main()
{
    int n=1;
    while(true)
    {    
        if(n%5==1&&n%6==5&&n%7==4&&n%11==10)
        {
        	cout<<n;
        	breat;
		}
    	n++;
	}
	return 0;
}

1263-8除不尽的数

不会

1265-爱因斯坦的数学题

#include<iostream>
using namespace std;
int main()
{
    int n=1;
    while(true)
    { 
        if(n%2==1&&n%3==2&&n%5==4&&n%6==5&&n%7==0)
        {
        	cout<<n;
        	breat;
		}
    	n++;
	}
	return 0;
}

1214-角谷猜想

#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int sum=0;
    while(n!=1)
    { 
        if(n%2==0)
        {
        	n=n/2;
		}
		else
		{
			n=n*3+1;
		}
		sum++;
	}
	cout<<sum;
	return 0;
}

1460-小明学游泳

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值