1 #include<iostream> 2 #include<iomanip> 3 using namespace std; 4 5 int main() 6 { 7 //freopen("acm.acm","r",stdin); 8 double sum; 9 double temp; 10 int n_temp; 11 int n; 12 cout<<"Cards Overhang "<<endl; 13 while(cin>>n) 14 { 15 n_temp = n; 16 sum = 0; 17 temp = 2; 18 while(n --) 19 { 20 sum += 1.0/temp; 21 temp += 2; 22 } 23 cout<<setw(5)<<n_temp<<setw(10)<<setiosflags(ios::fixed)<<setprecision(3)<<sum<<endl; 24 } 25 }
关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。
技术网站地址: vmfor.com