Printing a cross with given word | Letuscode
Given a string we have to print the characters of that string into a cross mark.
If the string is "12345", we need to print
string input="12345";
int len = input.size();
int i,j;
for( i = 0; i < len; i++)
{
for( j = 0; j < len; j++)
{
if( i == j || j == len-i-1)
cout << input[i];
else
cout << " ";
}
cout << endl;
}
return 0;
}
Read full article from Printing a cross with given word | Letuscode
Given a string we have to print the characters of that string into a cross mark.
If the string is "12345", we need to print
1 | 5 | |||
2 | 4 | |||
3 | ||||
2 | 4 | |||
1 | 5 |
This is printing the two diagonals of a square matrix filled the given string. Following is the simple code to print the same.
int main() {string input="12345";
int len = input.size();
int i,j;
for( i = 0; i < len; i++)
{
for( j = 0; j < len; j++)
{
if( i == j || j == len-i-1)
cout << input[i];
else
cout << " ";
}
cout << endl;
}
return 0;
}
Read full article from Printing a cross with given word | Letuscode