2015年天勤考研机试模拟赛 A 判断三角形

【思路】:采用atoi转换长度,两边只和大于第三边,两边之差小于第三边。

【AC代码】:

#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";}

,玩坏了可以选择重来,

2015年天勤考研机试模拟赛 A 判断三角形

相关文章:

你感兴趣的文章:

标签云: