Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
27656 唐心 字符串对比 C++ Accepted 2 MS 748 KB 488 2022-06-07 18:02:32

Tests(4/4):


Code:

#include<iostream> #include<cstring> #include<cstdlib> using namespace std; int main(){ char a[10],b[10]; scanf("%s %s",a,b); int n=strlen(a),m=strlen(b); int i,k; if(n!=m){//串长不等 printf("1\n"); } else{//假设两串相等 k=2; for(i=0;i<n;i++){ if(a[i]!=b[i]){ k=3;//若对应字符不等 if(32!=abs(a[i]-b[i])) {//若对应两字符距离不等于32 k=4; break; } } } printf("%d\n",k); } return 0; }