(C syntax) right triangle, right triangle

Source: Internet
Author: User

(C syntax) right triangle, right triangle

Knowledge point:

Logical expression usage

& |! Pay attention to the priority.

 

Content:

The three sides of the input triangle are used to determine whether the triangle is a right triangle. The output is Yes, the output is No, and the output is Error.

Input description:

One row. Enter three integers.

Output description:

Yes! Or No! Or Error! (Case Sensitive, no space before punctuation)

 

Input example:

3 4 5

Output example:

Yes!

 

 1 #include <stdio.h> 2 int main() 3 { 4  int a,b,c; 5  scanf("%d%d%d",&a,&b,&c); 6  if (a+b>c&&a+c>b&&b+c>a) 7  { 8   if (a*a+b*b==c*c||a*a+c*c==b*b||c*c+b*b==a*a) 9   {10    printf("Yes!\n");11   }12   else13   {14    printf("No!\n");15   }16  }17  else 18  {19   printf("Error!\n");20  }21  return 0;22 }

 


Question of using C language to write a right triangle

We don't look at the source program, we just need to understand it. The right triangle is to output N * Numbers in N rows. If you think about it like this, the program will soon come out, with two FOR loops, the first rule specifies the number of output layers. The for rule specifies the number of * Outputs per row,
So why is c <= B, the first line, B = 1, output one, the nth line, output N, B Represents the number of rows (the role in the first FOR) and the number of * output in each row (the role in the second ), you still have a wrong understanding of the for syntax. Because B is a variable, the values of B are different each time you enter for, and the-for is the constant volume, which indicates the number of output rows.

Urgent questions about English grammar

In my personal experience, I think English grammar is still very important in the senior high school entrance exam, because of the single choice of 80%, both the final type and part of the reading document are designed to test students' grammar. Grammar books on the market are generally relatively dead. We recommend that you accumulate experience in the exercise and do not pay too much attention to the books. Because some grammar knowledge won't be easily examined in the senior high school entrance exam, you should first check the single-choice questions of the local senior high school entrance exam over the years and classify the questions you don't know, find out where you have problems, and then find some questions to consolidate in this regard. It is best to have a wrong question book and make the wrong questions repeatedly until it is good. Finally, we recommend that you challenge the difficult "Longmen special answer", but do not try it if there is no answer.
As for the English review plan, I think we should follow the school now. After consolidating the content of the teacher's review every day, I need to find some reading and completion types and adjust the number of articles according to my own situation, every week, I need to find out the time for listening. I need to write an essay every one to two weeks and give it to the teacher for grading. I will review the usage of each word every day from May to May, finally, we need to make some comprehensive volumes. In this way, we should be able to grasp the main score. Interspersed with other questions, such as oral communication, should be better scored to avoid manual intervention.
Finally, I hope that my suggestions will help you with the exam review. I wish you a successful exam!

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.