/ Published in: C

Given a, b, c find which kind of triangle can be build with those values.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#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
