Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int horner(int wsp[],int st, int x);
- int main()
- {
- int *wspolczynniki;
- int stopien, argument;
- puts("Podaj stopien wielomianu: ");
- scanf("%d",&stopien);
- wspolczynniki = malloc(stopien+1*sizeof(int));
- //wczytanie współczynników
- int i;
- for(i=0;i<=stopien;i++)
- {
- printf("Podaj wspolczynnik stojacy przy potedze %d : ",stopien-i);
- scanf("%d",&wspolczynniki[i]);
- }
- puts("Podaj argument: ");
- scanf("%d",&argument);
- printf("W( %d ) = %d",argument,horner(wspolczynniki,stopien,argument));
- getchar();
- return 0;
- }
- int horner(int wsp[],int st, int x)
- {
- if(st==0)
- return wsp[0];
- return x*horner(wsp,st-1,x)+wsp[st];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement