Advertisement
huutho_96

tinh bieu thuc

May 22nd, 2015
436
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. //https://www.facebook.com/pages/C%C3%B9ng-h%E1%BB%8Dc-l%E1%BA%ADp-tr%C3%ACnh/632038696941833
  2. #include <iostream>
  3. using namespace std;
  4. struct SoHang
  5. {
  6. int HeSo, SoMu;
  7. };
  8. void main()
  9. {
  10. int y = 0;
  11. int n, x;
  12. SoHang *SH;
  13. cout << "Nhap bac cua da thuc: ";
  14. cin >> n;
  15. n = n + 1;//bao gom so hang co so mu = 0
  16. SH = new SoHang[n];
  17. for (int i = 0; i < n; i++)
  18. {
  19. cout << "Hang tu bac " << i << endl;
  20. cout << "Nhap he so: ";
  21. cin >> SH[i].HeSo;
  22. cout << "Nhap so mu: ";
  23. cin >> SH[i].SoMu;
  24. }
  25. cout << "Nhap gia tri x = ";
  26. cin >> x;
  27. for (int i = 0; i < n; i++)
  28. {
  29. y = y + SH[i].HeSo * pow(x, SH[i].SoMu);
  30. }
  31. cout << "Gia tri da thuc tai x = " << x << " la: y = " << y;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement