-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path112A_Petye_and_Strings.cpp
More file actions
89 lines (68 loc) · 2 KB
/
112A_Petye_and_Strings.cpp
File metadata and controls
89 lines (68 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/* A. Petya and Strings
time limit per test2 seconds
memory limit per test256 megabytes
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
*/
#include<bits/stdc++.h>
#include<string>
#include<algorithm>
using namespace std;
int main(){
string s1,s2;
cin>>s1>>s2;
transform(s1.begin(), s1.end(), s1.begin(), ::tolower);
transform(s2.begin(), s2.end(), s2.begin(), ::tolower);
if (s1 > s2)
cout<<"1";
else if (s1 < s2)
cout<<"-1";
else
cout<<"0";
return 0;
}#include<bits/stdc++.h>
#include<string>
#include<algorithm>
using namespace std;
int main(){
string s1,s2;
cin>>s1>>s2;
transform(s1.begin(), s1.end(), s1.begin(), ::tolower);
transform(s2.begin(), s2.end(), s2.begin(), ::tolower);
if (s1 > s2)
cout<<"1";
else if (s1 < s2)
cout<<"-1";
else
cout<<"0";
return 0;
}