解题思路:
注意事项:
参考代码:
#include <cstdio> #include <algorithm> #include <iostream> #include <string> using namespace std; string s1,s2; int judge(string s1, string s2){ int flag; if(s1[0] == s2[0]) { flag = 2; } else if(abs(s1[0] - s2[0]) == abs('A'-'a') || s1[0] - s2[0] == 0) flag = 3; else flag = 4; for(int i = 1; i < s1.length(); i++){ if(flag == 2 && s1[i] == s2[i]) { flag = 2; } else if((flag == 2 || flag == 3) && (abs(s1[i] - s2[i]) == abs('A'-'a') || s1[i] == s2[i])){ flag = 3; } else flag = 4; } return flag; } int main(void){ cin >> s1 >> s2; int ans = 0; if(s1.length() == s2.length()){ ans = judge(s1,s2); }else{ ans = 1; } cout << ans; return 0; }
0.0分
0 人评分
简单的a+b (C语言代码)浏览:827 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:530 |
C语言程序设计教程(第三版)课后习题6.3 (C语言代码)浏览:543 |
【绝对值排序】 (C++代码)浏览:720 |
WU-printf基础练习2 (C++代码)浏览:2061 |
【金明的预算方案】 (C++代码)浏览:873 |
C语言程序设计教程(第三版)课后习题8.8 (C语言代码)浏览:895 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:569 |
C语言程序设计教程(第三版)课后习题11.1 (C语言代码)浏览:525 |
简单的a+b (C语言代码)浏览:857 |