Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
Języki 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
Karol Pluto Prądzynski
Języki programowania
Commits
77b7b729
Commit
77b7b729
authored
1 week ago
by
Karol Pluto Prądzynski
Browse files
Options
Downloads
Patches
Plain Diff
lab6
parent
b73f973d
Branches
Branches containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lab6.c
+72
-0
72 additions, 0 deletions
lab6.c
with
72 additions
and
0 deletions
lab6.c
0 → 100644
+
72
−
0
View file @
77b7b729
#include
<stdio.h>
#include
<stdlib.h>
#include
<stdbool.h>
#include
<math.h>
#include
"lab6-3.h"
// do zadania 1
int
tablice
(
int
r
,
int
tab
[]){
int
suma
=
0
;
for
(
int
i
=
0
;
i
<
r
;
i
++
){
suma
+=
tab
[
i
];
}
return
suma
;
}
// do zadania 2
bool
czyPierwsza
(
int
n
){
if
(
n
<=
1
){
return
false
;
}
for
(
int
i
=
2
;
i
<
(
n
/
2
);
i
++
){
if
(
n
%
i
==
0
)
return
false
;
return
true
;
}
}
int
main
(){
int
rozmiar
=
0
,
sumaTab
=
0
;
int
liczba
;
int
masa
,
promien
;
float
v
;
// 1 zadanie
printf
(
"Podaj rozmiar tablicy:
\n
"
);
scanf
(
"%i"
,
&
rozmiar
);
int
tab
[
rozmiar
];
printf
(
"Podaj %i elementow tablicy:
\n
"
,
rozmiar
);
for
(
int
i
=
0
;
i
<
rozmiar
;
i
++
){
scanf
(
"%i"
,
&
tab
[
i
]);
}
sumaTab
=
tablice
(
rozmiar
,
tab
);
printf
(
"Suma elementow tablicy wynosi: %i
\n
"
,
sumaTab
);
// 2 zadanie
printf
(
"Podaj liczbe, program sprawdzi czy jest liczba pierwsza:
\n
"
);
scanf
(
"%i"
,
&
liczba
);
if
(
czyPierwsza
(
liczba
))
printf
(
"liczba %i jest pierwsza
\n
"
,
liczba
);
else
printf
(
"Liczba %i nie jest pierwsza
\n
"
,
liczba
);
// 3 zadanie
printf
(
"Podaj mase [kg] i promien [m], program obliczy predkosc ucieczki z pow. planety:
\n
"
);
scanf
(
"%i %i"
,
&
masa
,
&
promien
);
if
(
czyPoprawne
(
masa
,
promien
)){
v
=
predkosc
(
masa
,
promien
);
printf
(
"Predkosc ucieczki z planety o masie %i i promieniu %i wynosi:
\n
"
,
masa
,
promien
);
printf
(
"%f"
,
v
);
}
else
printf
(
"Niepoprawne wartosci
\n
"
);
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