Open utterances-bot opened 2 years ago
ai có thể cho em xin test case 1 vs test case 2 vs đc ko ạ em cảm ơn
test1 vs 2 là gì v mn?
test 1 và 2 là gì nhỉ sao lại lỗi tle (^_^)
Cho em xin cách làm ạ
cho em hỏi bài này của em bị sai chỗ nào ạ
using namespace std; int find(string str1, string str2) { int dem = 0; for (int i = 0; i < str1.length(); i++) for (int j = 0; j < str2.length(); j++) { if (str1[i] == str2[j]) dem++; } if (dem == str1.length()) return 0; else return 1; } int main() { int n; cin >> n; int arr[n], i = 0, n1 = n; string str1, str2; while(n >= 1 && n <= 100) { cin >> str1; cin >> str2; if (find(str1, str2) == 0) { arr[i] = str2.length() - str1.length(); } else { arr[i] = -1; } n--; i++; } for (int k = 0; k < n1; k++) { if (arr[k] != -1) cout << "Case " << k+1 << ":" << arr[k] << endl; else cout << "Case " << k+1 << ": IMPOSSIBLE" << endl; } }
using namespace std;
int main() { int t; cin>>t; cin.ignore(); for(int z = 1; z <= t; z++) { string s; cin >> s; string p; cin >> p; cout<< "Case #"<< z << ": "; int j = 0; for(int i = 0; i < p.size(); i++) { if(p[i] == s[j]) j++; } if(j == s.size()) cout << p.size() - s.size() << endl; else cout << "IMPOSSIBLE" << endl; } }
Đây là lời giải của mình đã AC. Nếu bạn đã cố gắng mà chưa làm được thì có thể tham khảo lời giải của mình.
```cpp
#include
Chi tiết bài tập - Luyện Code Online
https://oj.luyencode.net/problem/LC3A