2023-11-27 15:32:21 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <math.h>
|
2023-12-04 15:56:21 +01:00
|
|
|
#include "stdint.h"
|
|
|
|
#include "stdlib.h"
|
|
|
|
#include "newoldmain.h"
|
2023-11-27 15:32:21 +01:00
|
|
|
|
|
|
|
const float pi = 3.14;
|
|
|
|
|
2024-01-22 14:41:15 +01:00
|
|
|
float skruhu(float r) {
|
|
|
|
return pi * pow(r, 2);
|
2023-11-27 15:32:21 +01:00
|
|
|
}
|
|
|
|
|
2024-01-22 14:41:15 +01:00
|
|
|
float okruhu(float r) {
|
2023-11-27 15:32:21 +01:00
|
|
|
return 2 * pi * r;
|
|
|
|
}
|
|
|
|
|
2024-01-22 14:41:15 +01:00
|
|
|
float svalec(float r, float h) {
|
2023-11-27 15:32:21 +01:00
|
|
|
return (okruhu(r) * h) + 2 * skruhu(r);
|
|
|
|
}
|
|
|
|
|
2024-01-22 14:41:15 +01:00
|
|
|
float vvalec(float r, float h) {
|
2023-11-27 15:32:21 +01:00
|
|
|
return skruhu(r) * h;
|
|
|
|
}
|
|
|
|
|
2024-01-22 14:41:15 +01:00
|
|
|
void valec() {
|
2023-11-27 15:32:21 +01:00
|
|
|
float r = 0;
|
|
|
|
float h = 0;
|
|
|
|
float objem = 0;
|
|
|
|
float povrch = 0;
|
|
|
|
|
|
|
|
printf("\nZadaj polomer:");
|
|
|
|
scanf("%f", &r);
|
|
|
|
|
|
|
|
printf("\nZadaj vysku valca:");
|
|
|
|
scanf("%f", &h);
|
|
|
|
|
|
|
|
objem = vvalec(r, h);
|
|
|
|
povrch = svalec(r, h);
|
|
|
|
|
|
|
|
printf("\nObjem valca je %.2f a povrch je %.2f.", objem, povrch);
|
|
|
|
}
|
|
|
|
|
2024-01-22 14:41:15 +01:00
|
|
|
float strojuholnik(float a, float va) {
|
2023-11-27 15:32:21 +01:00
|
|
|
return (a * va) / 2;
|
|
|
|
}
|
|
|
|
|
2024-01-22 14:41:15 +01:00
|
|
|
float otrojuholnik(float a, float b, float c) {
|
2023-11-27 15:32:21 +01:00
|
|
|
return a + b + c;
|
|
|
|
}
|
|
|
|
|
2024-01-22 14:41:15 +01:00
|
|
|
void trojuholnikold() {
|
2023-11-27 15:32:21 +01:00
|
|
|
float a = 0;
|
|
|
|
float b = 0;
|
|
|
|
float c = 0;
|
|
|
|
float va = 0;
|
|
|
|
float obvod = 0;
|
|
|
|
float obsah = 0;
|
|
|
|
|
|
|
|
printf("\nZadaj stranu a:");
|
|
|
|
scanf("%f", &a);
|
|
|
|
|
|
|
|
printf("\nZadaj stranu b:");
|
|
|
|
scanf("%f", &b);
|
|
|
|
|
|
|
|
printf("\nZadaj stranu c:");
|
|
|
|
scanf("%f", &c);
|
|
|
|
|
|
|
|
printf("\nZadaj vysku na stranu a:");
|
|
|
|
scanf("%f", &va);
|
|
|
|
|
|
|
|
obvod = otrojuholnik(a, b, c);
|
|
|
|
|
|
|
|
obsah = strojuholnik(a, va);
|
|
|
|
|
|
|
|
printf("Obsah trojuholnika je %.2f a jeho obvod je %.2f.", obsah, obvod);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-01-22 14:41:15 +01:00
|
|
|
void parne() {
|
2023-11-27 15:32:21 +01:00
|
|
|
int cislo = 0;
|
|
|
|
printf("Zadaj cislo:");
|
|
|
|
|
|
|
|
scanf("%d", &cislo);
|
|
|
|
|
2024-01-22 14:41:15 +01:00
|
|
|
if (cislo % 2 == 0) {
|
2023-11-27 15:32:21 +01:00
|
|
|
printf("Cislo %d je parne.\n", cislo);
|
2024-01-22 14:41:15 +01:00
|
|
|
} else {
|
2023-11-27 15:32:21 +01:00
|
|
|
printf("Cislo %d je neparne.\n", cislo);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-01-22 14:41:15 +01:00
|
|
|
int porovnavanie(int cislo1, int cislo2, int cislo3) {
|
2023-11-27 15:32:21 +01:00
|
|
|
int min = 0;
|
|
|
|
|
2024-01-22 14:41:15 +01:00
|
|
|
if (cislo1 < cislo2) {
|
|
|
|
if (cislo1 < cislo3) {
|
2023-11-27 15:32:21 +01:00
|
|
|
min = cislo1;
|
|
|
|
|
2024-01-22 14:41:15 +01:00
|
|
|
} else {
|
2023-11-27 15:32:21 +01:00
|
|
|
min = cislo3;
|
|
|
|
}
|
2024-01-22 14:41:15 +01:00
|
|
|
} else {
|
|
|
|
if (cislo2 < cislo3) {
|
2023-11-27 15:32:21 +01:00
|
|
|
min = cislo2;
|
2024-01-22 14:41:15 +01:00
|
|
|
} else {
|
2023-11-27 15:32:21 +01:00
|
|
|
min = cislo3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return min;
|
|
|
|
}
|
|
|
|
|
2024-01-22 14:41:15 +01:00
|
|
|
int porovnavanietest(int *cisla, int pocet) {
|
2023-11-27 15:32:21 +01:00
|
|
|
int min = cisla[0];
|
2024-01-22 14:41:15 +01:00
|
|
|
for (uint16_t i = 0; i < pocet; i++) {
|
|
|
|
if (cisla[i] < min) {
|
2023-11-27 15:32:21 +01:00
|
|
|
min = cisla[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return min;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-01-22 14:41:15 +01:00
|
|
|
void porovnavaniecelok() {
|
2023-11-27 15:32:21 +01:00
|
|
|
int cislo1 = 0;
|
|
|
|
int cislo2 = 0;
|
|
|
|
int cislo3 = 0;
|
|
|
|
|
|
|
|
uint16_t pocet = 1;
|
|
|
|
|
|
|
|
int *cisla;
|
|
|
|
|
|
|
|
printf("Zadaj pocet:");
|
|
|
|
scanf("%d", &pocet);
|
|
|
|
cisla = malloc(pocet);
|
|
|
|
|
2024-01-22 14:41:15 +01:00
|
|
|
for (uint16_t i = 0; i < pocet; i++) {
|
2023-11-27 15:32:21 +01:00
|
|
|
printf("Zadaj cislo:");
|
|
|
|
scanf("%d", cisla);
|
|
|
|
cisla[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int max = 0;
|
|
|
|
int max2 = 0;
|
|
|
|
max2 = porovnavanietest(cisla, pocet);
|
|
|
|
printf("Cislo %d je najmensie(algo2)\n", max2);
|
|
|
|
}
|