Codeforces 112A-Petya and Strings(实现)
2 seconds
256 megabytes
standard input
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 stringslexicographically.
The letters' case does not matter, that is an uppercase letter is considered equivalent to the corresponding lowercase letter. Help Petya perform the comparison.
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.
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.
aaaa
aaaA
0
abs
Abz
-1
abcdefg
AbCdEfF
1
比較两个字符串的大小,不区分大写和小写。。
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
using namespace std;
const int INF = 0x3f3f3f3f;
#define LL long long
char s1[200], s2[200];
int main()
{
while (scanf("%s%s", s1, s2) != EOF) {
for (int i = 0; i < strlen(s1); i++) {
s1[i] = toupper(s1[i]);
} for (int i = 0; i < strlen(s2); i++) {
s2[i] = toupper(s2[i]);
} printf("%d\n", strcmp(s1, s2));
} return 0;
}
Codeforces 112A-Petya and Strings(实现)的更多相关文章
- Codeforces 385B Bear and Strings
题目链接:Codeforces 385B Bear and Strings 记录下每一个bear的起始位置和终止位置,然后扫一遍记录下来的结构体数组,过程中用一个变量记录上一个扫过的位置,用来去重. ...
- Codeforces 482C Game with Strings(dp+概率)
题目链接:Codeforces 482C Game with Strings 题目大意:给定N个字符串,如今从中选定一个字符串为答案串,你不知道答案串是哪个.可是能够通过询问来确定, 每次询问一个位置 ...
- 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 149 E. Martian Strings
正反两遍扩展KMP,维护公共长度为L时.出如今最左边和最右边的位置. . .. 然后枚举推断... E. Martian Strings time limit per test 2 seconds m ...
- CodeForces 832B Petya and Exam
B. Petya and Exam time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- A - Petya and Strings
Problem description Little Petya loves presents. His mum bought him two strings of the same size for ...
- CodeForces 362E Petya and Pipes
Petya and Pipes Time Limit: 1000ms Memory Limit: 262144KB This problem will be judged on CodeForces. ...
- 【24.34%】【codeforces 560D】Equivalent Strings
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- codeforces B. Petya and Staircases 解题报告
题目链接:http://codeforces.com/problemset/problem/362/B 题目意思:给出整数n和m,表示有n级楼梯和m级dirty的楼梯,接下来m个数表示对应是哪一个数字 ...
- CodeForces 682D Alyona and Strings (四维DP)
Alyona and Strings 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/D Description After re ...
随机推荐
- PHP PDO类
<?php //数据库连接类,不建议直接使用DB,而是对DB封装一层 //这个类不会被污染,不会被直接调用 class DB { //pdo对象 private $_pdo = null; // ...
- es6字符串、数值、Math的扩展总结
字符串的扩展 1.for...of遍历字符串 2.includes()判断字符串中是否包含某个字符串,返回bool 3.startsWith(),endsWith()分别盘对字符串的头部和尾部是否含有 ...
- Python进阶:@property 动态属性
Python进阶:@property 动态属性 Python 动态属性的概念可能会被面试问到,在项目当中也非常实用,但是在一般的编程教程中不会提到,可以进修一下. 先看一个简单的例子.创建一个 Stu ...
- Bzoj3566/洛谷P4284 [SHOI2014]概率充电器(概率dp)
题面 Bzoj 洛谷 题解 首先考虑从儿子来的贡献: $$ f[u]=\prod_{v \in son[u]}f[v]+(1-f[v])\times(1-dis[i]) $$ 根据容斥原理,就是儿子直 ...
- BZOJ 4810 [Ynoi2017]由乃的玉米田(莫队+bitset)
[题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=4810 [题目大意] 给出一个数列,有三种区间查询, 分别查询区间是否存在两个数乘积为x ...
- [TCO2013]Block3Checkers
题意:一个网格上有一些障碍和$3$个在网格边界上的棋子,你要添加一些障碍使得没有两个棋子四连通,问最少添加多少个障碍 官方题解——一张图教你做人... 三个棋子将网格边界分成三段,添加障碍后网格中一定 ...
- Hibernate 的HQL,QBC 查询语言
1.HQL:(Hibernate Query Language) 是面向对象的查询语言 1.实体查询 public void testQueryAllDept(){ String hql=" ...
- Codeforces Round #345 (Div. 2) E. Table Compression 并查集
E. Table Compression 题目连接: http://www.codeforces.com/contest/651/problem/E Description Little Petya ...
- Educational Codeforces Round 9 A. Grandma Laura and Apples 水题
A. Grandma Laura and Apples 题目连接: http://www.codeforces.com/contest/632/problem/A Description Grandm ...
- BZOJ 4029: [HEOI2015]定价 贪心
4029: [HEOI2015]定价 题目连接: http://www.lydsy.com/JudgeOnline/problem.php?id=4029 Description 在市场上有很多商品的 ...