Saturday, 8 September 2012

Converting 2D Matrix Into 1D Matrix

If you wish to convert your 2D Matrix into 1D matrix youwould be confused as to how would proceed.
No Worries Here is the code that will help you conver 2D Matrix in 1D Matrix.





#include<iostream.h>
#include<conio.h>
void main()
{   clrscr();
int a[3][3];
int b[9];
int i,j,k=0;

cout<<"Entered Elements into 3*3 matrix \n";
for(i=0;i<3;i++)
for(j=0;j<3;j++)
cin>>a[i][j];

cout<<"Matrix Entered By you is \n";
for(i=0;i<3;i++)
{for(j=0;j<3;j++)
  cout<<a[i][j]<<" ";
   cout<<endl;
}

cout<<endl;
cout<<endl;

for(i=0;i<3;i++)
{for(j=0;j<3;j++)
 b[k++]=a[i][j];

 }
cout<<"1-D Matri is \n";

cout<<endl;
for(k=0;k<9;k++)
cout<<b[k]<<" ";

 getch();

 }


11 comments:

  1. k should be declared as 0 after the two "cout<<endl;" statements, else it shows an error like " Undefined symbol 'k' "

    ReplyDelete
  2. K is initialized as 0 already

    ReplyDelete
  3. https://k2incenseonlineheadshop.com/
    info@k2incenseonlineheadshop.com
    k2incenseonlineheadshop Buy liquid incense cheap Buy liquid incense cheap For Sale At The Best Incense Online Shop

    ReplyDelete
  4. https://syntheticworldwide.com/
    sales@syntheticworldwide.com

    Buy cheap liquid herbal incense at your best online shop

    ReplyDelete
  5. https://syntheticworldwide.com/
    sales@syntheticworldwide.com

    Buy cheap liquid herbal incense at your best online shop

    ReplyDelete



  6. Our online store is one of the best in the supply of rare and high-grade (Mushrooms, Edibles. Psychedelics, and more)with absolute purity. All our products are tested to guarantee potency after production, during distribution and even storage. We ship globally in discreet and undetectable packaging using our network of trusted partners.
    psilosybin mushroom 2022, trusted magic mushroom site 2022,
    cheap liquid lsd, order cheap psychedelic mushroom,
    cheap magic mushroom, super quality shrooms,
    most potent psilocybin mushroom on the market,
    best microdosing mushrooms 2022, Golden teacher mushroom for sale,
    where to buy B+ magic mushroom, buy shrooms online ,
    buy psilocybin mushroom overnight shipping, effective microdosing for ptsd,
    buy mushroom truffles online cash on delivery, buy microdose capsules online 2021,
    magic mushrooms for mental illness for sale,
    buy mushies for anxiety/deppression and ptsd, cheap psilocybin mushroom, shrooms near me,
    where to buy psilocybin mushroom near me, cheap psychedelic mushroom for sale,
    buy caps/buttons cheap, best place to buy magic mushroom,
    buy cheap fungi mushrooms, cheap strong fungus, best quality spores for sale,
    buy mushroom grow kit online, buy fungi shrooms near me, cheapest magic mushrooms online,
    where to buy penis envy online, where to buy mexicanna online, buy microdose capsules online,
    best microdose capsule for sale,
    fungi mushroom for sale, best liquid cultures online, buy spores near me, buy Nirvana mushroom near me,
    buy pajaritos mushrooms near me, psychedelic mushroom near me, buy medicinal mushroom online,
    buy 5-MeO-DMT, buy dmt vape pen online, buy lsd tabs online, buy dmt online, where to buy dmt,
    lsd for sale, buy mushies near me, buy shrooms wholesale price, strong boomers for sale,
    Buy trippy shrooms online, buy penis envy, buy albino A+, buy amazonian cubensis,
    buy psilocybe cubensis, buy blue meanie, buy vietam cubensis, buy z strain shrooms,
    buy boomers cubensis online, buy cubensis buy golden teacher, buy liquid lsd online
    Our quality is the best you can find around and we sell in small/large quantities with guaranteed discreet delivery in good time Shipping




    website...https://megapsilocybin.com/
    call/text..+1(458) 201-6900
    email..sale@megapsilocybin.com

    ReplyDelete
  7. The 5 best casino bonuses and promotions: Play now
    Get to 나주 출장안마 know our players 태백 출장샵 and enjoy the fun and 밀양 출장마사지 excitement of slot machines and 의정부 출장안마 other games at casinos around 광주 출장마사지 the world, and keep you informed.

    ReplyDelete