Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <cstdio>
  4. using namespace std;
  5. int main(){
  6. string tab;
  7. cin>>tab;
  8. char n, m;
  9. int count = 0;
  10. cin>>n>>m;
  11. bool findFirst = false;
  12. int sizTab = tab.length();
  13. int countMin = sizTab + 1;
  14. for(int i = 0; i < sizTab; ++i){
  15. if(tab[i] == n){
  16. count = 0;
  17. findFirst = true;
  18. }
  19. else if (tab[i] == m && findFirst == true){
  20. countMin = min(count,countMin);
  21. count = 0;
  22. findFirst = false;
  23. }
  24. else count++;
  25. }
  26. if (countMin == sizTab + 1) cout<<0;
  27. else cout<<countMin;
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement