版权声明:本文为博主原创文章,未经博主允许不得转载 https://blog.csdn.net/qq_42812128/article/details/86669444
自从上一题看了一位大神的超级精简版for循环之后,我也想用一个超短的for循环,于是就有了下面的代码。
#include<iostream>
using namespace std;
int main(){
int n;//步数
double x,s=0,m=2;//s表示已经游的总路程,m是每次游泳的路程
cin>>x;
for(n=0;s<x;n++,s=s+m,m=m*0.98);
cout<<n;
return 0;
}