Advertisement
Aveneid

Takie se

Apr 9th, 2018
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.80 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. float a,b,c,x1,x2,i;
  6. int n;
  7.  
  8. float calcY(x){
  9.     return a*pow(x,2)+b*x+c;
  10. }
  11. int main()
  12. {
  13.     FILE *filestream;
  14.     filestream = fopen("out.txt","w");
  15.     do{
  16.         printf("\nPodaj zakres (x1 < x2) : ");
  17.         scanf("%f %f", &x1,&x2);
  18.     }while(x2<x1 || x2==x1);
  19.     printf("\n===\n");
  20.  
  21.  
  22.     do{
  23.         printf("\nPodaj ilosc probek: ");
  24.         scanf("%d",&n);
  25.     }while(n<2);
  26.     printf("\n===\n");
  27.  
  28.     do{
  29.         printf("\nPodaj wspolczynnik a: "); scanf("%f",&a);
  30.         printf("\nPodaj wspolczynnik b: "); scanf("%f",&b);
  31.         printf("\nPodaj wspolczynnik c: "); scanf("%f",&c);
  32.     }while(a==0 || b==0 || c==0);
  33.  
  34.     float step = abs((x2-x1))/n*1.00;
  35.  
  36.     for(i=1;i<=n;i++)
  37.          fprintf(filestream, "X:%f \t Y:%f \n",x1+step*n, calcY(x1+step*n));
  38.  
  39.     fclose(filestream);
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement