112A - Petya and Strings - CodeForces Solution


implementation strings *800

Please click on ads to support us..

Python Code:

a=input("").lower()
b=input("").lower()
f=0
for i in range(len(a)):
    if ord(a[i])>ord(b[i]):
        f=1
        break
    elif ord(a[i])<ord(b[i]):
        f=-1
        break
    else:
        f=0
print(f)

C++ Code:

#include <iostream>
#include<string>
#include<cctype>

using namespace std;

int main()
{
    string s;
    cin >> s;
    string str;
    cin >> str;
   for(int i = 0;i<s.size();i++){
       s[i] = tolower(s[i]);
       str[i] = tolower(str[i]);
   }
   if(str == s){
       cout << 0<<  endl;
   }
   else{
       
   
   for(int i = 0 ;i<s.size();i++){
       if(s[i]<str[i]){
           cout  << -1 <<endl;
           break;
           
       }
       else if(s[i]>str[i]){
           cout << 1 << endl;
           break;
       }
   }
   }

    return 0;
}


Comments

Submit
0 Comments
More Questions

1036D - Vasya and Arrays
1139C - Edgy Trees
37A - Towers
353A - Domino
409H - A + B Strikes Back
1262A - Math Problem
158C - Cd and pwd commands
194A - Exams
1673B - A Perfectly Balanced String
1104B - Game with string
1169B - Pairs
1567D - Expression Evaluation Error
78A - Haiku
1287A - Angry Students
1428A - Box is Pull
234B - Reading
581B - Luxurious Houses
1481C - Fence Painting
935A - Fafa and his Company
22A - Second Order Statistics
1720B - Interesting Sum
1720A - Burenka Plays with Fractions
3A - Shortest path of the king
1720C - Corners
574A - Bear and Elections
352B - Jeff and Periods
1244A - Pens and Pencils
1670A - Prof Slim
1189A - Keanu Reeves
678A - Johny Likes Numbers