Return to Snippet

Revision: 8834
at October 28, 2008 02:26 by jaircazarin


Updated Code
#include<stdio.h>
#define NONE -1
#define EQUILATERAL 0
#define ISOSCELES 1
#define SCALENE 3

int isTriangle(int a, int b, int c)
{
	if(a < 1 || b < 1 || c < 1)
		return NONE;
	if(a+b <= c || a+c <= b || c+b <= a)
		return NONE;
	if(a == b && a == c)
		return EQUILATERAL;
	if(a == b || b == c || a == c)
		return ISOSCELES;
	else
		return SCALENE;
}

int main()
{
	printf("%d\n", isTriangle(11,10,17));
	printf("%d\n", isTriangle(11,10,11));
	printf("%d\n", isTriangle(11,11,11));
	printf("%d\n", isTriangle(11,110,11));
	printf("%d\n", isTriangle(11,0,11));
	return 0;
}

Revision: 8833
at October 10, 2008 02:04 by jaircazarin


Initial Code
#include<stdio.h>
#define NONE -1
#define EQUILATERAL 0
#define ISOSCELES 1
#define SCALENE 3

int isTriangle(int a, int b, int c)
{
	if(a < 1 || b < 1 || c < 1)
		return NONE;
	if(a+b < c || a+c < b || c+b < a)
		return NONE;
	if(a == b && a == c)
		return EQUILATERAL;
	if(a == b || b == c || a == c)
		return ISOSCELES;
	else
		return SCALENE;
}

int main()
{
	printf("%d\n", isTriangle(11,10,17));
	printf("%d\n", isTriangle(11,10,11));
	printf("%d\n", isTriangle(11,11,11));
	printf("%d\n", isTriangle(11,110,11));
	printf("%d\n", isTriangle(11,0,11));
	return 0;
}

Initial URL

                                

Initial Description
Given a, b, c find which kind of triangle can be build with those values.

Initial Title
Type of Triangle

Initial Tags

                                

Initial Language
C