A - Petya and Strings
Problem description
Little Petya loves presents. His mum bought him two strings of the same size for his birthday. The strings consist of uppercase and lowercase Latin letters. Now Petya wants to compare those two strings lexicographically. The letters' case does not matter, that is an uppercase letter is considered equivalent to the corresponding lowercase letter. Help Petya perform the comparison.
Input
Each of the first two lines contains a bought string. The strings' lengths range from 1 to 100 inclusive. It is guaranteed that the strings are of the same length and also consist of uppercase and lowercase Latin letters.
Output
If the first string is less than the second one, print "-1". If the second string is less than the first one, print "1". If the strings are equal, print "0". Note that the letters' case is not taken into consideration when the strings are compared.
Examples
Input
aaaa
aaaA
Output
0
Input
abs
Abz
Output
-1
Input
abcdefg
AbCdEfF
Output
1
Note
If you want more formal information about the lexicographical order (also known as the "dictionary order" or "alphabetical order"), you can visit the following site:http://en.wikipedia.org/wiki/Lexicographical_order.
解题思路:先把两个字符串中的大写字母全部换成小写字母,然后用strcmp(s1,s2)函数比较两个字符串的大小,水过。
AC代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
char s1[],s2[];
cin>>s1>>s2;
for(int i=;s1[i]!='\0';++i){
if(s1[i]>='A'&&s1[i]<='Z')s1[i]+=;
if(s2[i]>='A'&&s2[i]<='Z')s2[i]+=;
}
if(strcmp(s1,s2)>)cout<<""<<endl;
else if(strcmp(s1,s2)<)cout<<"-1"<<endl;
else cout<<""<<endl;
return ;
}
A - Petya and Strings的更多相关文章
- codeforces水题100道 第二十四题 Codeforces Beta Round #85 (Div. 2 Only) A. Petya and Strings (strings)
题目链接:http://www.codeforces.com/problemset/problem/112/A题意:忽略大小写,比较两个字符串字典序大小.C++代码: #include <cst ...
- codeforces 112APetya and Strings(字符串水题)
A. Petya and Strings 点击打开题目 time limit per test 2 seconds memory limit per test 256 megabytes input ...
- Codeforces 112A-Petya and Strings(实现)
A. Petya and Strings time limit per test 2 seconds memory limit per test 256 megabytes input standar ...
- Codeforces 149 E. Martian Strings
正反两遍扩展KMP,维护公共长度为L时.出如今最左边和最右边的位置. . .. 然后枚举推断... E. Martian Strings time limit per test 2 seconds m ...
- CodeForces832-B. Petya and Exam
补的若干年以前的题目,水题,太菜啦_(:з」∠)_ B. Petya and Exam time limit per test 2 seconds memory limit per test 2 ...
- Codeforces Round #425 (Div. 2) Problem B Petya and Exam (Codeforces 832B) - 暴力
It's hard times now. Today Petya needs to score 100 points on Informatics exam. The tasks seem easy ...
- Codeforces Round #425 (Div. 2) B. Petya and Exam(字符串模拟 水)
题目链接:http://codeforces.com/contest/832/problem/B B. Petya and Exam time limit per test 2 seconds mem ...
- CodeForces 832B Petya and Exam
B. Petya and Exam time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- Codeforces Round #425 (Div. 2) B - Petya and Exam
地址:http://codeforces.com/contest/832/problem/B 题目: B. Petya and Exam time limit per test 2 seconds m ...
随机推荐
- Python 函数 day3
函数是组织好的,可重复使用的,用来实现单一,或相关联功能的代码段. 函数能提高应用的模块性,和代码的重复利用率.你已经知道Python提供了许多内建函数,比如print().但你也可以自己创建函数,这 ...
- CentOS7.2下安装php加速软件Xcache
说明: php安装目录:/usr/local/php php.ini配置文件路径:/usr/local/php/etc/php.ini Nginx安装目录:/usr/local/nginx Nginx ...
- 基础命令history
history 记录历史命令 环境变量: HISTSIZE: 命令历史记录的条数: HISTFILE: 命令历史记录的文件,~/.bash_history: HISTFILESIZE: 命令历史 ...
- django的时间问题
三个时间datetime.datetime.now().datetime.datetime.utcnow()与django.util.timezone.now()的区别 datetime.dateti ...
- 编译OpenWrt失败
/home/fly/work_dir/OpenWrt-SDK/OpenWrt-Test/trunk/scripts/download.pl "/home/fly/work_dir/OpenW ...
- WPF Style设置和模板化Template
WPF样式设置和模板化是一套功能(样式,模板,触发器和演示图版),可以为产品设置统一外观.类似于html的css,可以快速的设置一系列属性值到控件. 案例:ButtonStyle 这里创建了一个目标类 ...
- HTML5本地存储——Web SQL Database与indexedDB
虽然在HTML5 WebStorage介绍了html5本地存储的Local Storage和Session Storage,这两个是以键值对存储的解决方案,存储少量数据结构很有用,但是对于大量结构化数 ...
- ACDream - Chasing Girl
先上题目: Chasing Girl Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) ...
- Spring Boot开发HTTPS协议的REST接口
Spring Boot开发HTTP的REST接口流程在前文中已经描述过,见<SpringBoot开发REST接口>. 如需要支持HTTPS,只需要在如上基础上进行设置.修改/resourc ...
- cocoa 运行apple脚本文件的方法
NSString* path = [[NSBundle mainBundle] pathForResource:@"ScriptName" ofType:@"scpt&q ...