1 solutions
-
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
Information
- ID
- 16312
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By