Compare T-Shirt Sizes
Compare T-Shirt Sizes
传送门
Two T-shirt sizes are given: aa and bb. The T-shirt size is either a string M or a string consisting of several (possibly zero) characters X and one of the characters S or L.
For example, strings M, XXL, S, XXXXXXXS could be the size of some T-shirts. And the strings XM, LL, SX are not sizes.
The letter M stands for medium, S for small, L for large. The letter X refers to the degree of size (from eXtra). For example, XXL is extra-extra-large (bigger than XL, and smaller than XXXL).
You need to compare two given sizes of T-shirts aa and bb.
The T-shirts are compared as follows:
- any small size (no matter how many letters X) is smaller than the medium size and any large size;
- any large size (regardless of the number of letters X) is larger than the medium size and any small size;
- the more letters X before S, the smaller the size;
- the more letters X in front of L, the larger the size.
For example:
- XXXS < XS
- XXXL > XL
- XL > M
- XXL = XXL
- XXXXXS < M
- XL > XXXS
Input
The first line of the input contains a single integer tt (1 \le t \le 10^41≤t≤104) — the number of test cases.
Each test case consists of one line, in which aa and bb T-shirt sizes are written. The lengths of the strings corresponding to the T-shirt sizes do not exceed 5050. It is guaranteed that all sizes are correct.
Output
For each test case, print on a separate line the result of comparing aa and bb T-shirt sizes (lines "<", ">" or "=" without quotes).
Sample 1
Inputcopy | Outputcopy |
---|---|
6 XXXS XS XXXL XL XL M XXL XXL XXXXXS M L M |
< > > = < > |
判断语句的使用,梳理分类好就容易写了
#include <iostream>
#include <cstring>
using namespace std;int main()
{int n;cin >> n;string s1, s2;char c1, c2;int l1, l2;while (n--){cin >> s1>>s2;l1 = s1.length();l2 = s2.length();c1 = s1[l1-1];c2 = s2[l2-1];//cout << c1 << " " << c2 << endl;if (c1==c2){if (c1 == 'M'){cout << "=" << endl;}if (c1 == 'S'){if (l1 == l2){cout << "=" << endl;}else if (l1 > l2){cout << "<" << endl;}else{cout << ">" << endl;}}if (c1 == 'L'){if (l1 == l2){cout << "=" << endl;}else if (l1 < l2){cout << "<" << endl;}else{cout << ">" << endl;}}}if (c1 == 'L' && (c2 == 'M' || c2 =='S')){cout << ">" << endl;}if (c1 == 'S' && (c2 == 'M' || c2 == 'L')){cout << "<" << endl;}if (c1 == 'M'){if (c2 == 'S'){cout << ">" << endl;}if (c2 == 'L'){cout << "<" << endl;}}//cout << c1 << " " << c2 << endl;}
}
Compare T-Shirt Sizes相关推荐
- CF1741A Compare T-Shirt Sizes 题解
CF1741A Compare T-Shirt Sizes 题解 题目 链接 字面描述 题面翻译 题目描述 输入格式 输出格式 样例 #1 样例输入 #1 样例输出 #1 代码实现 题目 链接 htt ...
- mysql 代码怎么优化_MySQL 性能优化的简略办法
mysql 性能优化的简单办法 优化数据库最核心的实际上就是配置参数的调整.本文通过一个简单的参数调整,实现了对拥有一个几十万行表的 group by 优化的例子.通过这个简单的调整,数据库性能有了突 ...
- 敏捷整洁之道 -- 第三章 业务实践
敏捷整洁之道 -- 第三章 业务实践 0. 引子 1. 计划游戏 1.1 三元分析 1.2 故事和点数 1.3 故事 1.4 故事估算 1.5 对迭代进行管理 1.6 速率 2. 小步发布 3. 验收 ...
- 洛谷CF1741A Compare T-Shirt Sizes
写在前面:本文旨在记录个人算法学习(小新一枚) 题意 给定两个字符串 aa 和 bb 表示两件衣服的尺码,我们规定:字符串只能由字符 M(中等尺寸)组成或由几个字符 X(可以是 0 个)加上一个字符 ...
- windows增量到linux,Beyond Compare 3在windows和linux下实现提取增量包
需求:要实现在windows或linux下的自动对比打得WAR包,进行增量发布(缺点就是只能增量部署增加的和修改的,对删除的不能进行减量部署) 具体实现:利用Beyond Compare 3来实现,功 ...
- C++中的string::compare的使用
在C++中使用std::string编写字符串相关操作时,我经常使用find方法,其实在有些场景下需要判断字符串是否相同,因而需要使用compare方法.下面是我的测试样例: //descriptio ...
- java 比较器comparator_Java中比较器的使用Compare和Comparator
Comparable和Comparator接口都是为了对类进行比较,众所周知,诸如Integer,double等基本数据类型,java可以对他们进行比较,而对于类的比较,需要人工定义比较用到的字段比较 ...
- .NET平台开源项目速览(2)Compare .NET Objects对象比较组件
原文:.NET平台开源项目速览(2)Compare .NET Objects对象比较组件 .NET平台开源项目速览今天介绍一款小巧强大的对象比较组件.可以更详细的获取2个对象的差别,并记录具体差别,比 ...
- ERP系统管理员的工具箱 推荐几款优秀的数据比较同步工具 Data Compare and Sync tool...
最近一直在帮忙客户找程序方面的问题.当确定不是程序上的问题后,痛苦的过程就开始了:帮助客户修复计算错误的数据,也叫Data Fix.我们的ERP系统有1000多个表,有100个基础数据表,比如物料表, ...
最新文章
- 我的电脑点不开问题解决方法?
- linux-RPM安装
- Tomcat User 配置
- 产品经理如何提升自己的配色能力
- uva437巴比伦塔
- JavaWEB/JSP 中简单的验证码 springMVC
- 【less-24】基于SQLI的二次注入
- Linux命令行解析参数之getopt_long
- 《C++ Primer Plus 6th》读书笔记 - 第十一章 使用类
- Touch Panel 调试技巧 01
- uniapp app 腾讯云 IM 通讯 封装基础登录方法
- oracle 除数不能为0
- 39.JavaScript中Promise的基本概念、使用方法,回调地狱规避、链式编程
- win10系统开机自动修复失败的解决方法
- iOS使用颜色生成图片的暗黑适配
- 第二章 java语言基础
- Unity3D学习记录——NGUI Sprit3
- Nginx HTTP 健康检查
- 通过ONIE安装NOS系统
- 不笑找我系列 | 程序员爆笑漫画十条