A - Petya and Strings
Problem Link: Codeforces 112A
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
string a, b;
cin >> a>>b;
for (int i = 0;i < a.length();i++)
{
if (a[i] >= 'A' && a[i] <= 'Z')
a[i] += 32;
if (b[i] >= 'A' && b[i] <= 'Z')
b[i] += 32;
if (a[i] > b[i]) { cout << "1"; return 0; }
if (a[i] < b[i]) { cout << "-1";return 0; }
}
cout << "0" << endl;
return 0;
}
s1 = input().lower()
s2 = input().lower()
if (s1 < s2):
print(-1)
elif (s1 > s2):
print(1)
else:
print(0)
import java.util.Scanner;
public class PetyaAndStrings {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String word1 = input.next();
String word2 = input.next();
word1 = word1.toLowerCase();
word2 = word2.toLowerCase();
int result = word1.compareTo(word2);
if(result > 0){
result = 1;
}else if(result < 0){
result = -1;
}
System.out.println(result);
}
}