1 solutions
-
0
C :
#include<stdio.h> #include<string.h> #define N 100000 int main() { char s[3][N],t[3][N],x[N]; int i,l1,l2,j,k,l,m; for(i=0;i<3;i++) scanf("%s %s",s[i],t[i]); for(i=0;i<3;i++) { k=0,l=-1,m=0; l1=strlen(s[i]); l2=strlen(t[i]); for(j=0;j<l2;j++) { if(s[i][k]==t[i][j]) { k++; l++; } if(l==l1-1) { if(i!=2) printf("Case %d: yes\n",i+1); else printf("Case %d: yes",i+1); break; } else if(j==l2-1&&l!=l1-1) { if(i!=2) printf("Case %d: no\n",i+1); else printf("Case %d: no",i+1); } } } }C++ :
#include <iostream> #include <cstdio> using namespace std; int n; string a, b; int main() { for (int k = 1; k <= 3; k ++) { cin >> a >> b; int i, j; for (i = 0, j = 0; i < a.size() && j < b.size(); ) { if (a[i] == b[j]) { i ++; j ++; } else { j ++; } } printf("Case %d: ", k); if (i == a.size()) cout << "yes" << endl; else cout << "no" << endl; } return 0; }
- 1
Information
- ID
- 17215
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By