Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<iomanip>
- #include<cmath>
- using namespace std;
- int main()
- {
- int n,i;
- double s=0;
- cin>>n;
- for(i=1;i<=n;i++)
- {
- if(i%2) s=s+sqrt(i);
- else
- s=s-sqrt(i);
- }
- cout<<setprecision(4)<<fixed<<floor(s*10000)/10000;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement