All pastes #420809 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-04-02 12:30 UTC
rendered paste body
// k1f.cpp : Defines the entry point for the console application.
// oblicza pole trojkata wzorem herona i zwraca -1 jesli z podanych bokow nie mozna wykonac obliczen

#include "stdafx.h"
#include <math.h>

float pole(float a, float b, float c) {
float p, p2, w;
	if(a + b <= c || a + c <= b || b + c <= a) {
	w = -1;
	}
	else {
	p = (a + b + c) / 2;
	p2 = p * (p - a) * (p - b) * (p - c);
	w = sqrt(p2);
	}
return w;
}

int _tmain(int argc, _TCHAR* argv[])
{
	float a, b, c, p;
	printf("Podaj boki trojkata:\n");
	scanf("%f", &a);
	scanf("%f", &b);
	scanf("%f", &c);
	p = pole(a, b, c);
		if(p > 0) {
		printf("\nPole powierzchni wynosi %f\n", p);
		}
		else {
		printf("\nZ tego nie policzymy pola :)\n");
		}
	return 0;
}