Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
jezyki_programowania
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Kacper Śmieżewski
jezyki_programowania
Commits
1d94e2ac
Commit
1d94e2ac
authored
4 weeks ago
by
Kacper Śmieżewski
Browse files
Options
Downloads
Patches
Plain Diff
input handling and minor fixes
parent
901fc66a
Branches
Branches containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lab03/main2.c
+32
-25
32 additions, 25 deletions
lab03/main2.c
with
32 additions
and
25 deletions
lab03/main2.c
+
32
−
25
View file @
1d94e2ac
...
...
@@ -2,35 +2,42 @@
#include
<stdlib.h>
#include
<math.h>
#include
<complex.h>
#include
<stdbool.h>
int
main
()
{
printf
(
"Podaj liczby po spacji: "
);
float
a
=
0
,
b
=
0
,
c
=
0
;
scanf
(
"%f %f %f"
,
&
a
,
&
b
,
&
c
);
printf
(
"Rownanie: %.2fx^2 + %.2fx + %.2f = 0
\n
"
,
a
,
b
,
c
);
if
(
a
==
0
&&
b
==
0
&&
c
==
0
){
printf
(
"Podaj liczby po spacji: "
);
float
a
=
0
,
b
=
0
,
c
=
0
;
bool
correct
=
0
;
while
(
!
correct
){
if
(
scanf
(
"%f %f %f"
,
&
a
,
&
b
,
&
c
)
==
3
){
correct
=
1
;
printf
(
"Rownanie: %.2fx^2 + %.2fx + %.2f = 0
\n
"
,
a
,
b
,
c
);
if
(
a
==
0
&&
b
==
0
&&
c
==
0
){
printf
(
"Rownanie jest niezonaczone
\n
"
);
}
else
if
(
a
==
0
&&
b
==
0
){
printf
(
"Rownanie jest sprzeczne
\n
"
);
}
else
if
(
a
==
0
){
printf
(
"Rownanie jest liniowe
\n
"
);
printf
(
"Rozwiaznie rownania: %.2f"
,
-
c
/
b
);
}
else
if
(
a
==
0
&&
b
==
0
){
printf
(
"Rownanie jest sprzeczne
\n
"
);
}
else
if
(
a
==
0
){
printf
(
"Rownanie jest liniowe
\n
"
);
printf
(
"Rozwiaznie rownania: %.2f"
,
-
c
/
b
);
}
else
{
printf
(
"Rownanie jest kwadratowe
\n
"
);
if
(
b
*
b
-
4
*
a
*
c
<
0
){
printf
(
"Delta jest ujemna
\n
"
);
double
complex
x1
=
(
-
b
-
csqrt
(
b
*
b
-
4
*
a
*
c
))
/
(
2
*
a
);
double
complex
x2
=
(
-
b
+
csqrt
(
b
*
b
-
4
*
a
*
c
))
/
(
2
*
a
);
printf
(
"Rozwiaznie rownania: %.2f% + .2fi lub %.2f% + .2fi
\n
"
,
creal
(
x1
),
cimag
(
x1
),
creal
(
x2
),
cimag
(
x2
));
}
else
{
float
x1
,
x2
;
x1
=
(
-
b
-
sqrt
(
b
*
b
-
4
*
a
*
c
))
/
(
2
*
a
);
x2
=
(
-
b
+
sqrt
(
b
*
b
-
4
*
a
*
c
))
/
(
2
*
a
);
printf
(
"Rozwiaznie rownania: %.2f lub %.2f
\n
"
,
x1
,
x2
);
}
}
}
else
{
printf
(
"Rownanie jest kwadratowe
\n
"
);
if
(
b
*
b
-
4
*
a
*
c
<
0
){
printf
(
"Delta jest ujemna
\n
"
);
double
complex
x1
=
(
-
b
-
csqrt
(
b
*
b
-
4
*
a
*
c
))
/
2
*
a
;
double
complex
x2
=
(
-
b
+
csqrt
(
b
*
b
-
4
*
a
*
c
))
/
2
*
a
;
printf
(
"Rozwiaznie rownania: %.2f% + .2fi
\n
lub %.2f% + .2fi
\n
"
,
creal
(
x1
),
cimag
(
x1
),
creal
(
x2
),
cimag
(
x2
));
}
else
{
float
x1
,
x2
;
x1
=
(
-
b
-
sqrt
(
b
*
b
-
4
*
a
*
c
))
/
2
*
a
;
x2
=
(
-
b
+
sqrt
(
b
*
b
-
4
*
a
*
c
))
/
2
*
a
;
printf
(
"Rozwiaznie rownania: %.2f lub %.2f"
,
x1
,
x2
);
}
while
(
getchar
()
!=
'\n'
);
printf
(
"Podaj 3 LICZBY: "
);
}
return
0
;
}
return
0
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment