Oct 11
Oct 11
#include <iostream>
#include <string>
using namespace std;
int main()
{
string a, b;
cout << "Enter a string: \n";
cin >> a;
for(int i = a.length() - 1; i >= 0; --i)
{
b += a[i];
}
cout << b << "\n";
if (a == b)
cout << "Thí is a palindrome";
else
cout << "It is not a palindrome";
return 0;
}
Question 3:
Letter A:
#include <iostream>
using namespace std;
Letter B:
#include <iostream>
using namespace std;
int main() {
int height = 7;
for (int i = 0; i < height; i++) {
for (int j = 0; j < height; j++) {
// The left side of B
if (j == 0) {
cout << "*";
}
// Middle lines (there’s 3 of them)
else if ((i == 0 || i == height / 2 || i == height - 1) &&
j < height - 1) {
cout << "*";
}
// The curves
else if ((i > 0 && i < height / 2 && j == height - 1) ||
(i > height / 2 && i < height - 1 && j == height
- 1)) {
cout << "*";
}
// Gaps
else {
cout << " ";
}
}
cout << endl; //
}
return 0;
}