Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- string str;
- cout<<"Enter string"<<endl;
- getline(cin,str);
- const int len = str.length();
- for (int i = 1; i<len; i += 2)
- {
- cout << str[i];
- }
- for (int i = len % 2 ? len - 1 : len - 2; i >= 0; i -= 2)
- {
- cout << str[i];
- }
- cout << endl;
- system("pause");
- return 0;
- }
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- string str,slovo;
- int s=0;
- string::size_type k=0,pos=0;
- string razdel=",.:;!? ";
- cout<< "Enter string"<<endl;
- getline(cin,str);
- k=str.find_first_of(razdel,pos);
- while (k!=string::npos)
- {slovo=str.substr(pos,k-pos);
- if (ispunct(str[k])) pos=k+2; else pos=k+1;
- if (slovo[0]==slovo[slovo.length()-1]) s++;
- k=str.find_first_of(razdel,pos)
- }
Advertisement
Add Comment
Please, Sign In to add comment