注:此为c++代码
虽然我的代码无注释,但如想复制,必须完全搞懂代码所对应的题!
Dev c++这东西点进来的都有吧,详情见我的另一篇文章。
正式进入题解部分: (本人小白,大佬们请勿吐槽)
1085:
#include<bits/stdc++.h>
using namespace std;
int a=1;
double sum,b,c;
int main()
{
cin>>b;
c=b;
while(a<=10)
{
sum+=2*b;
b/=2.0;
a++;
}
cout<<sum-c<<endl<<b;
return 0;
}
1086:
#include<bits/stdc++.h>
using namespace std;
long int n,a;
int main()
{
cin>>n;
while(n!=1)
{
if(n%2)
{
cout<<n<<"*3+1="<<n*3+1<<endl;
n=n*3+1;
}
else
{
cout<<n<<"/2="<<n/2<<endl;
n/=2;
}
}