Advertisement
AnhVan1712

Untitled

Oct 28th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. void nhap (double &x, double &n);
  4. double tinhLuyThua (double x, double n);
  5. void xuat (double a);
  6. void main ()
  7. {
  8. double x,n;
  9. nhap (x,n);
  10. double a=tinhLuyThua (x,n);
  11. xuat (x);
  12. }
  13. void nhap (double &x, double &n)
  14. {
  15. scanf ("%lf%lf",&x,&n);
  16. }
  17. double tinhLuyThua (double x, double n)
  18. {
  19. double i=1;
  20. double s=0;
  21. while (i<=n)
  22. {
  23. s=s+pow (x,i);
  24. i++;
  25. }
  26. return s;
  27. }
  28. void xuat (double a)
  29. {
  30. printf ("%lf",a);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement