1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 | // Copyright 2021 Jeisson Hidalgo <jeisson.hidalgo@ucr.ac.cr> CC-BY 4.0
#include <omp.h>
#include <iostream>
#include <sstream>
// TODO(you): use for convenience or remove this procedure
void say(const std::string& text) {
std::ostringstream buffer;
buffer << omp_get_thread_num() << "/" << omp_get_num_threads()
<< ": " << text << std::endl;
std::cout << buffer.str();
}
int main(int argc, char* argv[]) {
const int thread_count = argc >= 2 ? atoi(argv[1]) : omp_get_max_threads();
std::string word;
// TODO(you): First task: read and print first word of the sentence
std::cin >> word;
std::cout << word;
// TODO(you): Second task: shuffle remaining words of the sentence
while (std::cin >> word) {
std::cout << ' ' + word;
}
// TODO(you): Third task: finish the sentence
std::cout << '.' << std::endl;
}
|