Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- void nacitaj(float koeficienty[], int stupen);
- float horner(float koeficienty[], float x, int stupen);
- int main(){
- int stupen;
- float koeficienty[100], x;
- printf("Stupen polynomu: ");
- scanf("%d", &stupen);
- if (stupen > 99){
- printf("Stack overflow, will now terminate");
- return 0;
- }
- nacitaj(koeficienty, stupen);
- printf("Zadaj x: ");
- scanf("%f", &x);
- printf("Hodnota polynomu v bode %g je: %g\n", x, horner(koeficienty, x, stupen));
- return 0;
- }
- void nacitaj(float koeficienty[], int stupen){
- int i;
- for (i = 0; i <= stupen; i++){
- printf("Zadaj %d-ty koeficient: ", stupen - i);
- scanf("%f", &koeficienty[i]);
- }
- }
- float horner(float koeficienty[], float x, int stupen){
- int i;
- float hodnota = koeficienty[0];
- for (i = 1; i <= stupen; i++)
- hodnota = hodnota*x + koeficienty[i];
- return hodnota;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement