"C Language" "algorithm" determines the triangle type based on three sides, and C language determines the triangle type

Source: Internet
Author: User

"C Language" "algorithm" determines the triangle type based on three sides, and C language determines the triangle type

1 # include <stdio. h> 2 3 // determine whether a triangle can be formed based on the length of the three sides, which can be composed of 4 5 int main () {6 int a, B, c at the edge length and angle respectively; 7 printf ("Enter the length of the three sides and separate them with commas: \ n"); 8 scanf ("% d, % d, % d", & a, & B, & c); 9 if (a <= 0 | B <= 0 | c <= 0) {10 printf ("enter a positive number"); 11 return 1; 12} 13 if (a> B + c | B> a + c | c> a + B) {14 printf ("cannot form a triangle \ n "); 15 return 1; 16} 17 printf ("by side length:"); 18 if (a = B | a = c | B = c) {19 if (a = B = c) printf ("equi triangle \ n"); 20 else printf ("equi triangle \ n "); 21} else {22 printf ("normal triangle \ n"); 23} 24 printf ("by angle :"); 25 if (a * a = B * B + c * c | B * B = a * a + c * c | c * c = B * B + a *) 26 printf ("right triangle \ n "); 27 else if (a * a> B * B + c * c | B * B> a * a + c * c | c * c> B * B + * a) 28 printf ("It is an acute triangle \ n"); 29 else30 printf ("It is an acute triangle \ n"); 31 return 0; 32}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.