Advertisement
fsimen

Untitled

Oct 24th, 2014
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <istream>
  5. #include <ostream>
  6. #include <stdexcept>
  7.  
  8.  
  9. using std::cin;
  10. using std::cout;
  11. using std::string;
  12. using std::endl;
  13. using std::vector;
  14. using std::istream;
  15. using std::ostream;
  16. using std::domain_error;
  17.  
  18. vector <string> read_phrase(istream &in) {
  19. string word;
  20. vector <string> phrase;
  21. bool phrase_end = false;
  22.  
  23. while (cin >> word && !phrase_end) {
  24. phrase.push_back(word);
  25. if (word[word.size() - 1] == '.')
  26. phrase_end = true;
  27. }
  28. if (phrase.size() == 0)
  29. throw domain_name("
  30. return phrase;
  31. }
  32.  
  33. string format_phrase(const vector<string> &v) {
  34. string out;
  35. for (vector<string>::const_iterator i=v.begin() ; i!=v.end(); i++)
  36. out+=*i;
  37. return out;
  38. }
  39.  
  40. vector <string> rotate_phrase(const vector <string> &v, int pos) {
  41. vector <string> out(v.begin()+pos, v.end());
  42.  
  43. if (pos > v.size())
  44. throw domain_error("Invalid rotation number");
  45. for (vector <string>::const_iterator i = v.begin();
  46. i!=v.begin() + pos; i++)
  47. out.push_back(*i);
  48. return out;
  49. }
  50.  
  51. int main()
  52. {
  53. vector <string> phrase;
  54. vector <vector <string> > phrase_perm;
  55. // phrase = read_phrase(cin);
  56. for (vector <string>::size_type i= 0;
  57. i!=phrase.size(); i++) {
  58. }
  59.  
  60. try {
  61. phrase = read_phrase(cin);
  62. } catch
  63.  
  64. phrase_perm = rotate_phrase
  65. cout << format_phrase(rotate_phrase(read_phrase(cin), 100));
  66. return 0;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement