From 0768a7ef34e4ad397b6b1a80edbd797bbf0d9529 Mon Sep 17 00:00:00 2001 From: Jakub Walas <s204451@student.pg.edu.pl> Date: Mon, 10 Mar 2025 08:53:51 +0000 Subject: [PATCH] Upload New File --- lab3/3zad2.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 lab3/3zad2.c diff --git a/lab3/3zad2.c b/lab3/3zad2.c new file mode 100644 index 0000000..55a15c0 --- /dev/null +++ b/lab3/3zad2.c @@ -0,0 +1,45 @@ +#include <stdio.h> +#include <math.h> +#include <complex.h> + +int main (){ + float a,b,c,e; + complex z1,z2; + printf("Podaj wspolczynnik a\n"); + scanf("%f",&a); + printf("Podaj wspolczynnik b\n"); + scanf("%f",&b); + printf("Podaj wspolczynnik c\n"); + scanf("%f",&c); + printf("%.1f*x^2+%.1f*x+%.1f=0\n",a,b,c); + if (a==0 && b==0.0 && c==0){ + printf("Rownanie nieoznaczone"); + return 0; + } + else if (a==0.0 && b==0){ + printf("Rownanie sprzeczne"); + return 0; + } + else if (a==0.0){ + printf("Rownanie liniowe\n"); + } + else{ + printf("Rownanie kwadratowe\n"); + } + if (a==0.0){ + printf("Rozwiazaniem jest %.1f",-c/b); + return 0; + } + e=b*b-4*a*c; + if(e==0){ + printf("Wynikiem rownania jest %.1f",-b/(2*a)); + return 0; + } + else if (e<0){ + printf("x1= %.1f%.1fi\n",(-b)/(2*a),(-sqrtf(-e))); + printf("x2= %.1f+%.1fi",(-b)/(2*a),(sqrtf(-e))); + return 0; + } + printf("Wynikami rownania sa %.1f i %.1f",(-b+sqrt(b*b-4*a*c))/(2*a),(-b-sqrt(b*b-4*a*c))/(2*a)); + return 0; +} -- GitLab