Bob103

ds

Dec 22nd, 2015
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. int main()
  5. {
  6. string str;
  7. cout<<"Enter string"<<endl;
  8. getline(cin,str);
  9. const int len = str.length();
  10. for (int i = 1; i<len; i += 2)
  11. {
  12. cout << str[i];
  13. }
  14. for (int i = len % 2 ? len - 1 : len - 2; i >= 0; i -= 2)
  15. {
  16. cout << str[i];
  17. }
  18. cout << endl;
  19. system("pause");
  20. return 0;
  21. }
  22.  
  23.  
  24.  
  25.  
  26.  
  27. #include <iostream>
  28. #include <string>
  29. using namespace std;
  30. int main()
  31. {
  32. string str,slovo;
  33. int s=0;
  34. string::size_type k=0,pos=0;
  35. string razdel=",.:;!? ";
  36. cout<< "Enter string"<<endl;
  37. getline(cin,str);
  38. k=str.find_first_of(razdel,pos);
  39. while (k!=string::npos)
  40. {slovo=str.substr(pos,k-pos);
  41. if (ispunct(str[k])) pos=k+2; else pos=k+1;
  42. if (slovo[0]==slovo[slovo.length()-1]) s++;
  43. k=str.find_first_of(razdel,pos)
  44. }
Advertisement
Add Comment
Please, Sign In to add comment