init
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
|
||||
|
||||
int trojuholnikalgo(int a, int b, int c){
|
||||
if( ((a+b) > c) && ((a+c) > b) && ((b+c) > a)){
|
||||
printf("Trojuholník sa da zostrojit");
|
||||
return 1;
|
||||
}
|
||||
else{
|
||||
printf("Trojuholník sa nedá zostrojiť");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void trojuholniktyp(int a, int b, int c){
|
||||
//rovnostranny
|
||||
if(a == b && a == c){
|
||||
printf(" a je rovnostranný\n");
|
||||
}
|
||||
//rovnoramenny
|
||||
else if(a == b || a == c || b == c) {
|
||||
printf("a je rovnoramenný\n");
|
||||
}
|
||||
//pravouhly
|
||||
else if ( (pow(a, 2) + pow(a, 2)) == pow(c, 2) || (pow(b, 2) + pow(c, 2)) == pow(a, 2) || (pow(a, 2) + pow(c, 2)) == pow(b, 2) ){
|
||||
printf(" a je pravouhly");
|
||||
}
|
||||
//nic z toho
|
||||
else {
|
||||
printf(" a je roznostranny");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void trojuholnik(){
|
||||
int a = 0;
|
||||
int b = 0;
|
||||
int c = 0;
|
||||
|
||||
printf("Zadaj cislo:");
|
||||
scanf("%d", &a);
|
||||
printf("Zadaj cislo:");
|
||||
scanf("%d", &b);
|
||||
printf("Zadaj cislo:");
|
||||
scanf("%d", &c);
|
||||
if (trojuholnikalgo(a, b, c) == 1) {
|
||||
trojuholniktyp(a, b, c);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main(){
|
||||
|
||||
trojuholnik();
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user