Advertisement
Paszta

Horn

Feb 6th, 2020
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void zad4(){
  6. //cout << "aaa" << endl;
  7.  
  8. int n, c, wynik;
  9. cout << "Podaj stopien wielomianu" << endl;
  10. cin >> n;
  11. int tab[n+1];
  12. for(int i = 0; i<n+1; i++){
  13. cout << " Podaj wartosc a[" << i << "]";
  14. cin >> tab[i];
  15. }
  16.  
  17. cout << "Podaj C wielomianu" << endl;
  18. cin >> c;
  19.  
  20. for (int i =1; i <=n; i++){
  21. tab[i] = tab[i-1]*c+tab[i];
  22. }
  23. wynik = tab[n-1];
  24. cout << " Wynik dla c: " << c <<"wynosi:" << wynik << endl;
  25. }
  26.  
  27. void zad5(){
  28. int n, c, wynik;
  29. cout << "Podaj stopien wielomianu" << endl;
  30. cin >> n;
  31. int tab[n+1];
  32. for(int j = 0; j<n; j++){
  33. cout << " Podaj wartosc a[" << j << "]";
  34. cin >> tab[j];
  35. }
  36.  
  37. cout << "Podaj C wielomianu" << endl;
  38. cin >> c;
  39.  
  40. for (int i =n; i > 0; i--){
  41. for (int j = 1; j < i ; j++){
  42.  
  43. tab[j] = tab[j-1]*c + tab[j];
  44. if(j==i-1)
  45. cout << tab[j] << endl;
  46. }
  47. }
  48. cout << " Wynik wynosi:" << wynik << endl;
  49.  
  50.  
  51.  
  52. }
  53.  
  54. int main()
  55.  
  56. {
  57. int wybor;
  58. do{
  59. cout << " Ktore zadanie pokazac?" << endl;
  60. cout << "1. Zadanie nr 4" << endl;
  61. cout << "2. Zadanie nr 5 " << endl;
  62. cout << "3. Zadanie nr 6 " << endl;
  63. cout << "4. Koniec programu" << endl;
  64. cin >> wybor;
  65. switch(wybor){
  66. case 1:
  67. cout << "WYNIKI ZADANIA NR 4" << endl;
  68. zad4();
  69. break;
  70. case 2:
  71. cout << "WYNIKI ZADANIA NR 2" << endl;
  72. zad5();
  73. break;
  74. case 3:
  75. cout << "WYNIKI ZADANIA NR 7" << endl;
  76. break;
  77. case 4:
  78. cout << "Zakonczono program" << endl;
  79. break;
  80. default:
  81. cout << "Podano zly numer polecenia" << endl;
  82. break;
  83. }
  84.  
  85. }
  86. while(wybor!=4);
  87.  
  88. return 0;
  89. }
  90.  
  91.  
  92. // w(c) = bn
  93. // dlugosc tab n+1
  94. //W(2) = 96
  95. //W(x) = (x-2)(x^6+2x^5+4x^4+6x^3+12x^2+24x+47)+96
  96.  
  97. //W(x)= (x+1)(4x^4+3x^2+2x+5) +0
  98. //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement