Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- float a,b,c,x1,x2,i;
- int n;
- float calcY(x){
- return a*pow(x,2)+b*x+c;
- }
- int main()
- {
- FILE *filestream;
- filestream = fopen("out.txt","w");
- do{
- printf("\nPodaj zakres (x1 < x2) : ");
- scanf("%f %f", &x1,&x2);
- }while(x2<x1 || x2==x1);
- printf("\n===\n");
- do{
- printf("\nPodaj ilosc probek: ");
- scanf("%d",&n);
- }while(n<2);
- printf("\n===\n");
- do{
- printf("\nPodaj wspolczynnik a: "); scanf("%f",&a);
- printf("\nPodaj wspolczynnik b: "); scanf("%f",&b);
- printf("\nPodaj wspolczynnik c: "); scanf("%f",&c);
- }while(a==0 || b==0 || c==0);
- float step = abs((x2-x1))/n*1.00;
- for(i=1;i<=n;i++)
- fprintf(filestream, "X:%f \t Y:%f \n",x1+step*n, calcY(x1+step*n));
- fclose(filestream);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement