A. Petya and Strings
原题传送门
题目描述
给你两个字符串按字典序进行比较,不区分大小写
分析
先将字符串格式化,即将字符串中所有字符全部变为小写,再进行比较
代码
#include <bits/stdc++.h>
using namespace std;const int maxn = 1e2 + 10;string s1, s2;void init (string &s) {for (int i = 0; i < s.length(); i++) s[i] = tolower(s[i]);
}int main() {ios::sync_with_stdio(false);cin >> s1 >> s2;init (s1);init (s2);if (s1 < s2) cout << "-1" << endl;if (s1 == s2) cout << "0" << endl;if (s1 > s2) cout << "1" << endl;return 0;
}