Advertisement
nguyenhappy92

Tính và in ra biểu thức A

Oct 27th, 2015
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. //
  2. // Khai bao cac ham thu vien neu co
  3. #include<stdio.h>
  4. #include<conio.h>
  5.  
  6. void main()
  7. {
  8. int n;
  9. float x;
  10. scanf("%d",&n);
  11. scanf("%f",&x);
  12. long double t=(x*x) +x +1;
  13. long double m=(x*x) - x +1;
  14. long double k=1;
  15. long double p=1;
  16. long double s=0;
  17. if(n==0)
  18. {
  19. printf("2");
  20. }
  21. else
  22. {
  23.  
  24. for(int i=1;i<=n;i++)
  25. {
  26. k=k*t;
  27. p=p*m;
  28. s=s+ p +k;
  29. }
  30. printf("%.4lf",s);
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement