博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
codeforces 112APetya and Strings(字符串水题)
阅读量:5975 次
发布时间:2019-06-19

本文共 1884 字,大约阅读时间需要 6 分钟。

A. Petya and Strings
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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.

Sample test(s)
Input
aaaaaaaA
Output
0
Input
absAbz
Output
-1
Input
abcdefgAbCdEfF
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
  • 比較字符串,不分大写和小写,相等输出0,大于输出1,小于输出-1。
  • 代码:
  • #include 
    #include
    using namespace std;int my_strcmp(char c[],char s[]){ int k=strlen(c),i; for(i=0;i
    ='A'&&c[i]<='Z') c[i]+=32; if(s[i]>='A'&&s[i]<='Z') s[i]+=32; } return strcmp(c,s);}int main(){ int k; char c[101],s[101]; while(cin>>c) { cin>>s; k=my_strcmp(c,s); cout<
    <
本文转自mfrbuaa博客园博客,原文链接:http://www.cnblogs.com/mfrbuaa/p/5073170.html,如需转载请自行联系原作者
你可能感兴趣的文章
我的友情链接
查看>>
HTTP协议详解
查看>>
自动生成 java 测试 mock 对象框架 DataFactory-01-入门使用教程
查看>>
Go语言开发(十六)、Go语言常用标准库六
查看>>
小梅科普:白帽子-高端信息安全培训
查看>>
JavaScript学习总结(9)——JS常用函数(一)
查看>>
Maven+SpringMVC+MyBatis实现系统(一)
查看>>
易宝典文章——如何在Exchange 2010中使用PowerShell文本文件批量移动邮箱
查看>>
智能dns 根据地区解析
查看>>
VS2012配置Git并连接到osc@git
查看>>
索尼高清影视技术学院参观观后感
查看>>
jQuery 文本编辑器插件 HtmlBox 使用
查看>>
怎么看自己服务器的带宽?
查看>>
go的错误处理
查看>>
apache2.4.4的安装过程
查看>>
php5.3安装oracle的扩展oci8与pdo_oci
查看>>
发送超长短信的协议格式
查看>>
CentOS 6.x 快速安装L2TP ***
查看>>
mysql主主复制(双主复制)配置步骤
查看>>
一篇文章能够看懂基础源代码之JAVA篇
查看>>