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 ...
随机推荐
- iOS标准库中常用数据结构和算法之查找
参数: key: [in] 要查找的元素.base:[in] 数组元素的首地址.nelp: [in/out] 数组的元素个数指针.width: [in] 数组中每个元素的尺寸.compar: [in] ...
- 使用脚手架创建vue项目之后会有很多警告,如何关闭它!
依次打开build→webpack.base.conf.js文件,然后找到createLintingRule,把里面的内容选择性的删除即可,就是这么easy;
- PostgreSQL使用总结
最近项目用到了PostgreSQL数据库,网上一堆教程,这里自己整理一下做个笔记: 1,下载安装,我这边安装在Windows7,在这里找到大象一样的标志: 2,双击打开,这里的话按流程直接走: 3,这 ...
- defer, panic, recover使用总结
1. defer : 延迟调用.多个defer,依次入栈,在函数即将退出时,依次出栈调用 package main import "fmt" func main() { defer ...
- django访问静态变量的设置
在项目的urls.py文件中 默认urlpatterns是空的列表需要填入url匹配的路由,默认使用static from django.conf.urls import include, url f ...
- 洛谷 P1348 Couple number
题目描述 任何一个整数N都能表示成另外两个整数a和b的平方差吗?如果能,那么这个数N就叫做Couple number.你的工作就是判断一个数N是不是Couple number. 输入输出格式 输入格式 ...
- 洛谷 P1041 传染病控制
P1041 传染病控制 题目背景 近来,一种新的传染病肆虐全球.蓬莱国也发现了零星感染者,为防止该病在蓬莱国大范围流行,该国政府决定不惜一切代价控制传染病的蔓延.不幸的是,由于人们尚未完全认识这种传染 ...
- OGNL是什么
OGNL表达式是(Object-Graph Navigation Language)是对象图形化导航语言.OGNL是一个开源的项目,Struts2中默认使用OGNL表达式语言来显示数据.与Serlve ...
- ubuntu设置不睡眠的方法
Ubuntu系统不睡眠设置方法:要完成这个设置Ubuntu有两种方法:第一种是打开 System Settings –> Power,中文版是打开系统设置 -> 电源),然后进行设置.但不 ...
- Mac OSX:添加host地址
Mac OSX的hosts文件位于/private/etc/hosts.记得用sudo权限编辑即可.在文件中添加如下内容: xxx.xxx.xxx.xxx (ip地址) abc.com(你的h ...