-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinvertstringes.cpp
More file actions
49 lines (35 loc) · 865 Bytes
/
Copy pathinvertstringes.cpp
File metadata and controls
49 lines (35 loc) · 865 Bytes
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include<iostream>
#include<vector>
using namespace std;
vector<string> esercizio(const vector<string>& vec)
{
vector<string> result(vec.size());
//int j = 0;
for (int i = vec.size() - 1; i >= 0; i--)
{
result[vec.size()-i-1] = vec[i]; //
//j++;
}
return result;
}
int main()
{
/*
Scrivere un programma che dato un testo (semplice), restituisca
lo stesso testo in cui l'ordine delle righe è invertito.
Esempio (input):
Benvenuti al corso di /n
Programmazione 2 /n
O-Z /n
(output)
O-Z /n
Programmazione 2 /n
Benvenuti al corso di /n
*/
vector<string> vec1{ "Benvenuti al corso di",
"Programmazione 2", "O - Z"};
vector<string> result = esercizio(vec1);
for (int i = 0; i < result.size(); i++)
cout << result[i] << endl;
return 0;
}