- #1
shivajikobardan
- 674
- 54
I want to make a program that takes strings as input. eg: physicsforums. And writes that using x'es.
example c of physicsforums should look like this.
I've written the program for this.
But I want to generalize? Any guidance available?
example c of physicsforums should look like this.
I've written the program for this.
Code:
#include <iostream>
using namespace std;
int main()
{
int size;
cout << "Enter the size of the pattern: ";
cin >> size;
for (int i = 0; i < size*2-1; i++)
{
for (int j = 0; j < size; j++)
{
if ((((i==0||i==2*size-2)&&j>1)||(i==1||i==2*size-3)&&(j==1||j==size-1))|| (j==0&&(i>1&&i<2*size-3)))
cout << "X";
else
cout << " ";
}
cout << endl;
}
return 0;
}
But I want to generalize? Any guidance available?