Advertisement
Guest User

Untitled

a guest
May 20th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.89 KB | None | 0 0
  1. // Name: Jeroen Kemna - 465556
  2. // Class: EMT1B
  3.  
  4.  
  5. #include <iostream>
  6. #include <string>
  7. #include <vector>
  8. #include <cctype>
  9.  
  10. using namespace std;
  11.  
  12. string poem()
  13. {
  14.     return  "How I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics."
  15.             "All of thy geometry, Herr Planck, is fairly hard, and if the lectures were boring or tiring, "
  16.             "then any odd thinking was on quartic equations again.";
  17. }
  18.  
  19. vector<string> list_words(const string& s)
  20. //  pre:    s is a string with one or more sentences; s is not empty;
  21. //          words contain only character a..z or A..Z
  22. //          words in s are separated from each other by a space character, plus optional punctuation marks such as comma or dot
  23. //  post:   returns a vector of strings were each vector element is one separate word from string s
  24. //          the order of word in the vector is the same as the order of words in string s
  25. {
  26.     // PLAATS HIER JOUW SOURCE CODE
  27.     // ...
  28.    
  29.    
  30. }
  31.  
  32. vector<int> count_letters(const vector<string>& v)
  33. //  pre:    v is a vector of strings, were each vector element contains a word consisting of only characters a..z or A..Z
  34. //  post:   returns a vector of integers in which each vector element contains the number of characters of each word
  35. //          e.g. if v[7] contains "course", the return value of index [7] is 6
  36. //          the order of the values in the return vector is the same as the order in the vector v
  37. {
  38.     // PLAATS HIER JOUW SOURCE CODE
  39.     // ...
  40.    
  41.    
  42. }
  43.  
  44. void print(const vector<int>& v)
  45. //  pre:    v is a vector of integers
  46. //  post:   the elements of v are printed on the console in the according to the given format
  47. //          v[0]',' followed by all other elements without spacing
  48. {  
  49.     // PLAATS HIER JOUW SOURCE CODE
  50.     // ...
  51.    
  52.    
  53. }
  54.  
  55. int main()
  56. {
  57.     string text = poem();
  58.     vector<string> words = list_words(text);
  59.     vector<int> numbers = count_letters(words);
  60.     print(numbers);
  61.     system("pause");
  62.     return 0;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement