C++循环题

8除不尽的数

#include<iostream>
using namespace std;
int main()
{
    int n=1;
    while(true)
    {
        
    int l=n/8;
    int l2=n/8/8;
    int a=l2/8;
        if(n%8==1&&l%8==1&&l2%8==7&&n%17==4&&n/17%17==15&&n/17/17==a*2) 
        {
            cout<<n;
            break;
        }
        n++;
    
    }
    return 0;
}

爱因斯坦的数学题

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

角谷猜想

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

求恰好使s=1+1/2+1/3+...1/n的值大于X时n的值

#include<iostream>
using namespace std;
int main()
{
    int x,n;
    cin>>x;
    float s;
    s=0;
    n=1;
    while(s<=x)
    {
        s=s+1.0/n;
        n++;
    }
    cout<<n-1;
    return 0;
}

小明学游泳

#include<iostream>
using namespace std;
int main()
{
    float l,sum=2,a=2;
    int i=1;
    cin>>l;
    while(sum<l)
    {
        sum=sum+a;
        a=a*0.98;
        i++;
    }
    cout<<i;
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值