Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void zad4(){
- //cout << "aaa" << endl;
- int n, c, wynik;
- cout << "Podaj stopien wielomianu" << endl;
- cin >> n;
- int tab[n+1];
- for(int i = 0; i<n+1; i++){
- cout << " Podaj wartosc a[" << i << "]";
- cin >> tab[i];
- }
- cout << "Podaj C wielomianu" << endl;
- cin >> c;
- for (int i =1; i <=n; i++){
- tab[i] = tab[i-1]*c+tab[i];
- }
- wynik = tab[n-1];
- cout << " Wynik dla c: " << c <<"wynosi:" << wynik << endl;
- }
- void zad5(){
- int n, c, wynik;
- cout << "Podaj stopien wielomianu" << endl;
- cin >> n;
- int tab[n+1];
- for(int j = 0; j<n; j++){
- cout << " Podaj wartosc a[" << j << "]";
- cin >> tab[j];
- }
- cout << "Podaj C wielomianu" << endl;
- cin >> c;
- for (int i =n; i > 0; i--){
- for (int j = 1; j < i ; j++){
- tab[j] = tab[j-1]*c + tab[j];
- if(j==i-1)
- cout << tab[j] << endl;
- }
- }
- cout << " Wynik wynosi:" << wynik << endl;
- }
- int main()
- {
- int wybor;
- do{
- cout << " Ktore zadanie pokazac?" << endl;
- cout << "1. Zadanie nr 4" << endl;
- cout << "2. Zadanie nr 5 " << endl;
- cout << "3. Zadanie nr 6 " << endl;
- cout << "4. Koniec programu" << endl;
- cin >> wybor;
- switch(wybor){
- case 1:
- cout << "WYNIKI ZADANIA NR 4" << endl;
- zad4();
- break;
- case 2:
- cout << "WYNIKI ZADANIA NR 2" << endl;
- zad5();
- break;
- case 3:
- cout << "WYNIKI ZADANIA NR 7" << endl;
- break;
- case 4:
- cout << "Zakonczono program" << endl;
- break;
- default:
- cout << "Podano zly numer polecenia" << endl;
- break;
- }
- }
- while(wybor!=4);
- return 0;
- }
- // w(c) = bn
- // dlugosc tab n+1
- //W(2) = 96
- //W(x) = (x-2)(x^6+2x^5+4x^4+6x^3+12x^2+24x+47)+96
- //W(x)= (x+1)(4x^4+3x^2+2x+5) +0
- //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement