limun11

Untitled

Jan 7th, 2016
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. float suma(int, float);
  7. int main()
  8. {
  9. int n;
  10. float x;
  11.  
  12. cin >> n;
  13. while (n < 0)
  14. {
  15. cin >> n;
  16. }
  17. cin >> x;
  18. cout << "Suma: " << suma(n, x) << endl;
  19. system("PAUSE");
  20. return 0;
  21. }
  22.  
  23. float suma(int n, float x)
  24. {
  25. float sum = 0;
  26. for (int i = 1; i <= n; i++)
  27. {
  28. sum = sum + pow(sin(x),i);
  29. }
  30. return sum;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment