Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Name: Jeroen Kemna - 465556
- // Class: EMT1B
- #include <iostream>
- #include <string>
- #include <vector>
- #include <cctype>
- using namespace std;
- string poem()
- {
- return "How I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics."
- "All of thy geometry, Herr Planck, is fairly hard, and if the lectures were boring or tiring, "
- "then any odd thinking was on quartic equations again.";
- }
- vector<string> list_words(const string& s)
- // pre: s is a string with one or more sentences; s is not empty;
- // words contain only character a..z or A..Z
- // words in s are separated from each other by a space character, plus optional punctuation marks such as comma or dot
- // post: returns a vector of strings were each vector element is one separate word from string s
- // the order of word in the vector is the same as the order of words in string s
- {
- // PLAATS HIER JOUW SOURCE CODE
- // ...
- }
- vector<int> count_letters(const vector<string>& v)
- // pre: v is a vector of strings, were each vector element contains a word consisting of only characters a..z or A..Z
- // post: returns a vector of integers in which each vector element contains the number of characters of each word
- // e.g. if v[7] contains "course", the return value of index [7] is 6
- // the order of the values in the return vector is the same as the order in the vector v
- {
- // PLAATS HIER JOUW SOURCE CODE
- // ...
- }
- void print(const vector<int>& v)
- // pre: v is a vector of integers
- // post: the elements of v are printed on the console in the according to the given format
- // v[0]',' followed by all other elements without spacing
- {
- // PLAATS HIER JOUW SOURCE CODE
- // ...
- }
- int main()
- {
- string text = poem();
- vector<string> words = list_words(text);
- vector<int> numbers = count_letters(words);
- print(numbers);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement