Code: Select all
Removed because accepted!!
Moderator: Board moderators
Code: Select all
Removed because accepted!!
Code: Select all
20
3 6 -1
5 3 5
6 2 9
1 2 7
0 9 3
6 0 6
2 6 1
8 7 9
2 0 2
3 7 5
9 2 2
8 9 7
3 6 1
2 9 3
1 9 4
7 8 4
5 0 3
6 1 0
6 3 2
0 6 1
Code: Select all
Case 1: Invalid
Case 2: Isosceles
Case 3: Invalid
Case 4: Invalid
Case 5: Invalid
Case 6: Invalid
Case 7: Invalid
Case 8: Scalene
Case 9: Invalid
Case 10: Scalene
Case 11: Invalid
Case 12: Scalene
Case 13: Invalid
Case 14: Invalid
Case 15: Invalid
Case 16: Scalene
Case 17: Invalid
Case 18: Invalid
Case 19: Invalid
Case 20: Invalid
Code: Select all
1
3 3 3
Code: Select all
Case 1: Equilateral
Code: Select all
if (a == b == c)
Code: Select all
if (a == b && b == c)
Code: Select all
#include <iostream>
using namespace std;
int main()
{
long long N, a, b, c;
cin >> N;
for (long long i = 0; i < N; i++)
{
cin >> a >> b >> c;
if ((a + b) <= c || (a + c) <= b || (b + c) <= a)
cout << "Case " << i + 1 << ": Invalid" << endl;
else if ((a == b) && (a == c))
cout << "Case " << i + 1 << ": Equilateral" << endl;
else if ((a == b) || (a == c) || (a == b))
cout << "Case " << i + 1 << ": Isosceles" << endl;
else
cout << "Case " << i + 1 << ": Scalene" << endl;
}
return 0;
}
what is the difference between the first and the last condition??else if ((a == b) || (a == c) || (a == b))
Code: Select all
#include<stdio.h>
int main(){
long long int c,tc,a[3],i,j,t;
scanf("%lld",&tc);
for(c=1;c<=tc;c++){
scanf("%lld%lld%lld",&a[0],&a[1],&a[2]);
for(i=0;i<2;i++){
for(j=0;j<2-i;j++){
if(a[j]<a[j+1]){
t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
}
}
printf("Case %lld: ",c);
if((a[0]<=(a[1]+a[2]))&&a[0]>0&&a[1]>0&&a[2]>0){
if(a[0]==a[1]&&a[1]==a[2])
printf("Equilateral\n");
else if(a[0]==a[1]||a[1]==a[2]||a[2]==a[0])
printf("Isosceles\n");
else
printf("Scalene\n");
}
else printf("Invalid\n");
}
return 0;
}
Code: Select all
got acc
Code: Select all