include iostream include string using namespace std void getMemory str

 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
#include <iostream>
#include <string>
using namespace std;
void getMemory(string*& str, int n){
str = new string[n];
}
void outputLine(string*& str, int countStr){
int i, j;
for (i = 0; i < countStr; i++){
for (j = 0; j < str[i].length(); j++){
cout << str[i].substr(str[i].length() - j - 1, 1);
}
cout << endl;
}
}
int main()
{
int i, countStr = 0;
string *str;
cout << "Enter the numbers of rows: ";
cin >> countStr;
getMemory(str, countStr);
for (i = 0; i < countStr; i++){
cin.ignore();
getline(cin,str[i]);
if (str[i].length() > 80){
cout << "String more than 80 characters!" << endl;
return 0;
}
}
outputLine(str, countStr);
delete[] str;
return 0;
}