I'll put an example of what I want.
A A
R R
M M
A
N N
D D
O O
But the same spaces have to be horizontal, as in the vertical, have to be squared.
Thank you
Is this good?
#include <iostream>
#include <string>
using namespace std;
int main() {
const string c = "ARMANDO";
int t = c.length() - 1;
for (int i = 0; i <= t; i++) {
for (int j = 0; j <= t; j++) {
cout << (i == j || i == t - j ? c[i] : ' ');
}
cout << '\n';
}
}
The trick is that i == j
is the main diagonal and i == t - j
is the secondary diagonal.
I, yesterday after a lot of fighting I succeeded.
I want to thank everyone who helped and gave me ideas.
Thank you.
I leave the resolution here.
#include <iostream>
#include <string>
using namespace std;
int main(){
cout << "Introduza nome: ";
string name;
getline(cin, name);
for(int line = 0; line < name.size(); line++){
for(int space=0; space < name.size();space++){
if(space == line){
cout << name[line];
}
else{
if(space == name.size()-line-1){
cout << name[line];
}
else{
cout << " ";
}
}
}
cout << endl;
}
return 0;
}