求助!
查看原帖
求助!
1160674
kkkisbigsb楼主2024/7/10 11:06

##代码大部分对,但是只能判断一次(一次只输出一种) 本蒟蒻在这里请教一下各位神犇##

//yee 
#include <iostream>
#include <cmath>
using namespace std;

int d(int a, int b, int c) {
   int max = a;
   if (b > max) {
   	max = b;
   }
   if (c > max) {
   	max = c;
   }
   return max;
}

string sjxpd(int a, int b, int c) {
   int max = d(a, b, c);
   int sum = a*a + b*b + c*c - max*max;
   
   if (a <= 0 || b <= 0 || c <= 0) {
   	return "Not triangle";
   	
   	if (a + b <= c || a + c <= b || b + c <= a) {
   		return "Not triangle";
   		
   //等腰,等边三角形 
   		if (a == b && b == c) {
   			return "Equilateral triangle";
   			
   			if (a == b || a == c || b == c) {
   				return "Isosceles triangle";
   				
   //锐角,钝角,直角三角形 
   				if (pow(max, 2) > sum) {
   					return "Obtuse triangle";
   					
   					if (pow(max, 2) < sum) {
   						return "Acute triangle";
   						
   						if (pow(max, 2) == sum) {
   							return "Right triangle";
   							
   						}
   					}
   				}
   			}
   		}
   	}c
   }
}

int main() {
   int s1, s2, s3;
   cin >> s1 >> s2 >> s3;
   
   string t = sjxpd(s1, s2, s3);
   cout << t << endl;
   
   return 0;
}

本蒟蒻第一次发讨论,如果哪里错了请指出

2024/7/10 11:06
加载中...