/ Published in: C
Given a, b, c find which kind of triangle can be build with those values.
Expand |
Embed | Plain Text
#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() { return 0; }
Comments
Subscribe to comments
You need to login to post a comment.

In the second
ifstatement, it should be `(Sure wish they'd implement Markdown correctly...)
In the second
ifstatement, it should be<=. E.g., if a=1, b=1, and c=2, it can't be a triangle.