Editorial
A triangle is equilateral if all its sides are equal. If it is not equilateral, check if it is isosceles – this requires two sides to be equal. If the triangle is neither equilateral nor isosceles, then it is scalene.
Algorithm realization
Read the input data.
scanf("%d %d %d",&a,&b,&c);
Check if the triangle is equilateral.
if ((a == b) && (b == c)) puts("1"); else
Check if the triangle is isosceles.
if ((a == b ) || (a == c) || (b == c)) puts("2"); else
Otherwise, the triangle is scalene.
puts("3");
Java realization
import java.util.*; public class Main { public static void main(String[] args) { Scanner con = new Scanner(System.in); int a = con.nextInt(); int b = con.nextInt(); int c = con.nextInt(); if ((a == b) && (b == c)) System.out.println("1"); else if ((a == b ) || (a == c) || (b == c)) System.out.println("2"); else System.out.println("3"); con.close(); } }
Python realization
Read the input data.
a, b, c = map(int, input().split())
Check if the triangle is equilateral.
if a == b and b == c: print("1") else:
Check if the triangle is isosceles.
if a == b or a == c or b == c: print("2") else:
Otherwise, the triangle is scalene.
print("3")