Showing posts with label nice one program. Show all posts
Showing posts with label nice one program. Show all posts

Tuesday, 15 March 2016

Program To Print The Mirror Image of an Array in C++

"Nice One Program"

#include<iostream.h>
#include<conio.h>

void main()
{  clrscr();
  int a[7][7];  int r,col;
  cout<<"Enter The number Of Rows and Columns:";
  cin>>r;
  cout<<endl;
  cin>>col;

  cout<<"\n\n";
  cout<<"Enter The Elements Row wise\n";

  int i,j;

  for(i=0;i<r;i++)
  for(j=0;j<col;j++)     //Array Input
  cin>>a[i][j];

cout<<"\n\n";

  for(i=0;i<r;i++)
{ cout<<endl;
  for(j=0;j<col;j++)
  cout<<a[i][j]<<" "; //Printing Original

  cout<<"-->";

  for(j=col-1;j>=0;j--) //Printing Mirror Img
  cout<<a[i][j]<<" ";

}
getch();

}




Friday, 19 February 2016

Program To Find "PERMUTAION" of String in C++

"Nice One Program"

// Here Is The CODE for The program

//Observe it Carefully
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
int main()
{  char a[10],b[10],i,j;
   int l1,l2;
   clrscr();
   cout<<"PROGRAM TO CHECK PERMUTATION\n\n";

   cout<<"Enter The Original Word:-";
   cin>>a;
   cout<<"\nEnter The Word For checking Permutation:-\n\n";
   cin>>b;
   l1 = strlen(a);
   l2 = strlen(b);

   // HERE WILL  THE ACTUAL THING START

    if(l1!=l2)
   { cout<<"It Is NOT a Permutation Of Given Number\n";   }

    else

{ // sorting  for original
     int t1,t2;char t;

     for(i=0;i<l1;i++)
     for(j=0;j<l1-1-i;j++)
   {
       t1=a[j];
       t2=a[j+1];

       if(t1>t2)
      { t=a[j];
 a[j]=a[j+1];
 a[j+1]=t;
 }
   }


    //sorting Second one
    for(i=0;i<l1;i++)
    for(j=0;j<l1-1-i;j++)
    { t1=b[j];
      t2=b[j+1];
      if(t1>t2)
     {
       t=b[j];
       b[j]=b[j+1];
       b[j+1]=t;
     }
    }

   if(strcmp(a,b)==0)
   cout<<"\n\nYES IT IS A PERMUTAION OF GIVEN";
   else
   cout<<"\n\nIT IS NOT A PERMUTAION OF GIVEN";
}

   getch();    return 0;
     }


HERE ARE BOTH THE OUTPUTS: