Advertisement
apl-mhd

Bappy sir MIrror

Mar 16th, 2017
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.13 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. using namespace std;
  4.  
  5. struct mirror{
  6.    
  7.     char data;
  8.     struct mirror *next;
  9.    
  10. };
  11. typedef struct mirror node;
  12.  
  13.    
  14.  
  15.  
  16. void inputdata(node *head[], int row, int col){
  17.    
  18.     int  i, j;
  19.     node *temp;
  20.    
  21.    
  22.    
  23.     //cout<<row<<col<<endl;
  24.    
  25.     for(i=0; i<row; i++){
  26.        
  27.        
  28.         for(j=0; j<col; j++){
  29.            
  30.             if(head[i] == NULL){
  31.                
  32.                 head[i] = new node();
  33.                 cin>>head[i]->data;
  34.                 //head[i]->data = j;
  35.                 head[i]->next=NULL;
  36.                
  37.                 }
  38.             else{
  39.                
  40.                 temp = new node();
  41.                 cin>>temp->data;
  42.                 //temp->data = j;
  43.                 temp->next= head[i];
  44.                 head[i] = temp;
  45.                
  46.                 }
  47.            
  48.        
  49.         }
  50.        
  51.    
  52.     }
  53.    
  54.  
  55. }
  56.  
  57. void display(node *head[], int row){
  58.    
  59.         node *temp;
  60.        
  61.         int i;
  62.        
  63.     for(i=0; i<row; i++){
  64.        
  65.        
  66.         temp=head[i];
  67.        
  68.         while(temp !=NULL){
  69.                
  70.             printf("%c", temp->data);
  71.            
  72.             temp=temp->next;
  73.         }
  74.         cout<<endl;
  75.    
  76.     }
  77. }
  78.  
  79.  
  80.  
  81.  
  82. int main(int argc, char **argv)
  83. {
  84.    
  85.     node *head[100]={NULL};
  86.    
  87.     int row, col;
  88.     cout<<"Enter row and column"<<endl;
  89.     cin>>row>>col;
  90.     inputdata(head, row , col);
  91.     cout<<endl<<endl;
  92.      display(head, row);
  93.    
  94.    
  95.     return 0;
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement