Advertisement
Guest User

kodas

a guest
Nov 11th, 2013
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. #include <string>
  4.  
  5. #include <string.h>
  6.  
  7. using namespace std;
  8.  
  9. int main ()
  10.  
  11. {
  12.  
  13. int counter=1, found = 0, i = 0;
  14.  
  15. cout << "Iveskite simbolius:";
  16.  
  17. std::string str, str2="";
  18.  
  19. std::getline(std::cin, str);
  20.  
  21. unsigned a = str.find (' ',0);
  22.  
  23. while(str[i] != char(32)) {
  24.  
  25. str2+=str[i];
  26.  
  27. i++;
  28.  
  29. }
  30.  
  31. cout<< "Pirmas zodis:";
  32.  
  33. cout<<str2<<endl;
  34.  
  35. found = str.find(str2, found+1);
  36.  
  37. while(found!=std::string::npos)
  38.  
  39. {
  40.  
  41. counter++;
  42.  
  43. found = str.find(str2, found+1);
  44.  
  45. }
  46.  
  47. cout<< "Pasikartojo zodziu eiltueje: "<< counter << endl;
  48.  
  49. system("pause");
  50.  
  51. return 0;
  52.  
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement