C++编程:计算小球弹跳距离和高度
#include<bits/stdc++.h> using namespace std; int main(){ int n; double h=100,s=100; cin>>n; for(int i=2;i<=n;i++){ h/=2; s+=h*2; } cout<<'第'<<n<<'次落地时,共经过'<<fixed<<setprecision(4)<<s<<'米,反弹高度是'<<fixed<<setprecision(4)<<h<<'米。'; return 0; }
原文地址: https://www.cveoy.top/t/topic/njm0 著作权归作者所有。请勿转载和采集!