Advertisement
RusSimona

ex88 pg63

Apr 9th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. #include<iostream>
  2. #include<iomanip>
  3. #include<cmath>
  4. using namespace std;
  5. int main()
  6. {
  7. int n,i;
  8. double s=0;
  9. cin>>n;
  10. for(i=1;i<=n;i++)
  11. {
  12. if(i%2) s=s+sqrt(i);
  13. else
  14. s=s-sqrt(i);
  15. }
  16. cout<<setprecision(4)<<fixed<<floor(s*10000)/10000;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement