Search
#include <stdio.h> #include <math.h> float zaokrouhleni (float c, int n) { float x = pow(10, n); float p = 0.5; if (c < 0) p = -0.5; return ((int)(c*x + p))/x; } int main() { float cislo; int pocet; scanf("%f%i", &cislo, &pocet); printf("%.*f", pocet, zaokrouhleni(cislo, pocet)); return 0; }
#include <stdio.h> #include <math.h> float heron (int a, int b, int c) { float s, S; s = (a + b + b)/2.0; S = sqrt(s*(s-a)*(s-b)*(s-c)); return S; } int main() { unsigned int a, b, c; if (scanf("%i%i%i", &a, &b, &c) != 3) { return 101; } if ((a+b) < c || (b+c) < a || (a+c) < b || a < 1 || b < 1 || c < 1) { return 102; } printf("S = %0.2f\n", heron(a, b, c)); return 0; }