#include <iostream>
using namespace std;
struct node
{
char c;
struct node* next;
};
struct node* head[100];
int main()
{
int r, a, i, j, k;
char h;
cout<<"Please Enter Row and Column: ";
cin >> r >> a;
for(i = 0; i < r; i ++)
{
head[i] = NULL;
for(j = 0; j < a; j ++)
{
cin >> h;
struct node* tem;
tem = new node;
tem->c = h;
tem->next = NULL;
if(head[i] == NULL)
{
head[i] = tem;
}
else
{
struct node* it;
it = head[i];
while(it->next != NULL)
{
it= it->next;
}
it->next = tem;
}
}
}
cout << endl;
for(i = 0; i < r; i ++)
{
struct node* it ;
for(j = a-1; j >= 0; j --)
{
it = head[i];
k = j;
while(k --)
{
it = it -> next;
}
cout << it->c;
}
cout << endl;
}
return 0;
}
Output
Please Enter Row and Column: 5 5
**...
...**
*.*..*
..***
***..
...**
**...
..*.*
**..*
.****
Add your comment