1 条题解
-
0
C :
#include<stdio.h> #include<string.h> int main() { char a[1002],b[1002]; while(~scanf("%s%s",a,b)){ int i,j,k,t=0; int len=strlen(a); k=0; for(i=0;i<len;i++) { if(a[i]!=b[i] && k==0) { j=i; k++; } else if(a[i]!=b[i] && k==1) { t += (i-j); k=0; } } printf("%d\n",t); } return 0; }
C++ :
#include <cstring> #include <cstdio> using namespace std ; char str1[1010] ; char str2[1010] ; int main() { while( ~scanf("%s%s" , str1 , str2 ) ) { int res = 0 ; int len1 = strlen(str1) ; for( int i = 0 ; i < len1-1 ; i ++ ) { if( str1[i] != str2[i] ) { res ++ ; if( str1[i+1] == '*' ) { str1[i+1] = 'o' ; } else str1[i+1] = '*' ; } } printf("%d\n" , res ) ; } return 0 ; }
- 1
信息
- ID
- 3446
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者