求助,80
查看原帖
求助,80
518660
封禁用户楼主2021/12/11 15:23
#include<iostream>
using namespace std;
int main()
{
    int firstep=2;
    float target;
    int steps;cin>>target;
    if(target!=0)
    {float steplist[100];steplist[0]=firstep;
    for(int i=1;i<=99;i++)
    {
        steplist[i]=steplist[i-1]*0.98;
    }
    float sum=0;
    for(int x=0;x<=99;x++)
    {
        sum+=steplist[x];
        if(sum>=target)
        {
            steps=x+1;
            cout<<steps;
            break;
        }
        else    continue;
    }
    return 0;}
    else return 1;
}
2021/12/11 15:23
加载中...