2015 tianqin postgraduate test simulation competition A judgment triangle, 2015 triangle

Source: Internet
Author: User

2015 tianqin postgraduate test simulation competition A judgment triangle, 2015 triangle

[Idea]: Use the atoi conversion length. The two sides are only greater than the third side, and the difference between the two sides is less than the third side.

[AC code ]:

#include <iostream>#include <algorithm>#include <cstdio>#include <cstring>using namespace std;#define MAX 100+10int main(){//freopen("in.txt", "r", stdin);//freopen("out.txt", "w", stdout);int i = 0, tri[3];for (i = 0;  i < 3; i++){int j = 0, n = 0, len;char temp[10], length[5+1];cin >> n;while (n--){cin >> temp;if (!strcmp(temp, "one"))length[j++] = '1';else if (!strcmp(temp, "two"))length[j++] = '2';else if (!strcmp(temp, "three"))length[j++] = '3';else if (!strcmp(temp, "four"))length[j++] = '4';else if (!strcmp(temp, "five"))length[j++] = '5';else if (!strcmp(temp, "six"))length[j++] = '6';else if (!strcmp(temp, "seven"))length[j++] = '7';else if (!strcmp(temp, "eight"))length[j++] = '8';else if (!strcmp(temp, "nine"))length[j++] = '9';else if (!strcmp(temp, "zero"))length[j++] = '0';}length[j] = '\0';tri[i] = atoi(length);}if ((tri[0]+tri[1]>tri[2]) && (abs(tri[0]-tri[1])<tri[2]))cout << "YES";elsecout << "NO";}


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.