Results 1 to 4 of 4
  1. #1
    Alpha Geek The Incredible's Avatar
    Join Date
    May 2005
    Location
    Planet Incredible
    Posts
    579

    Default Incredible Input Incredible Output (ProgLang-C++)(Comp-TC++)

    Here're two progs to transpose and mxn matrix and reverse the same.

    Code:
    //TO REVERSE A 3X4 MATRIX.//
    #include<iostream.h>
    #include<conio.h>
    #include<iomanip.h>
    void main()
    {
    clrscr();
    int a[3][4];
    for(char i=0;i<3;++i)
       {
       for(char j=0;j<4;++j)
          cin>>a[i][j];
       }
    for(i=2;i>=0;--i)
       {
       for(char j=3;j>=0;--j)
          cout<<setw(2)<<a[i][j]<<" ";
       cout<<endl;
       }
    getch();
    }
    Code:
    //TO TRANSPOSE A MXN MATRIX.//
    #include<iostream.h>
    #include<conio.h>
    #include<iomanip.h>
    void main()
    {
    clrscr();
    int a[3][4];
    cout<<"ENTER THE ELEMENTS OF ARRAY : ";
    for(char i=0;i<3;++i)
       {
       for(char j=0;j<4;++j)
          cin>>a[i][j];
       }
    for(i=0;i<4;++i)
       {
       for(char j=0;j<3;++j)
          cout<<setw(3)<<a[j][i]<<" ";
       cout<<endl;
       }
    getch();
    }
    Give the Input :
    01 02 03 04
    05 06 07 08
    00 00 00 00

    You'll get the Output :
    Case I:
    00 00 00 08
    00 07 06 05
    04 03 02 01
    Case II:
    01 05 08
    02 06 00
    03 07 00
    04 00 00

    What is making the output go wrong ??

  2. #2
    Commander in Chief QwertyManiac's Avatar
    Join Date
    Jul 2005
    Posts
    6,657

    Default Re: Incredible Input Incredible Output (ProgLang-C++)(Comp-TC++)

    Am getting both right, but using a normal int counter set (i,j) rather than a char one.

    Input:
    Code:
    01 02 03 04
    
    05 06 07 08
    
    00 00 00 00
    Output (Reverse):
    Code:
     0  0  0  0 
    
     8  7  6  5 
    
     4  3  2  1
    Output (Transpose):
    Code:
      1   5   0 
    
      2   6   0 
    
      3   7   0 
    
      4   8   0
    Harsh J
    www.harshj.com

  3. #3
    Alpha Geek The Incredible's Avatar
    Join Date
    May 2005
    Location
    Planet Incredible
    Posts
    579

    Default Re: Incredible Input Incredible Output (ProgLang-C++)(Comp-TC++)

    So, just because of the use of char(i,j) set, the results are altering ?

  4. #4
    Commander in Chief QwertyManiac's Avatar
    Join Date
    Jul 2005
    Posts
    6,657

    Default Re: Incredible Input Incredible Output (ProgLang-C++)(Comp-TC++)

    Just tried it with char (i,j) too, but it does the same thing, my output is all right.

    Maybe you need to add char to both the counter usage parts, like ISO C++ demands?

    Like this:
    Code:
    //TO TRANSPOSE A MXN MATRIX.//
    #include<iostream>
    #include<iomanip>
    
    using namespace std;
    
    main()
    {
    int a[3][4];
    cout<<"ENTER THE ELEMENTS OF ARRAY : ";
    for(char i=0;i<3;++i)
       {
       for(char j=0;j<4;++j)
          cin>>a[i][j];
       }
    for(char i=0;i<4;++i)
       {
       for(char j=0;j<3;++j)
          cout<<setw(3)<<a[j][i]<<" ";
       cout<<endl;
       }
    }
    Harsh J
    www.harshj.com

Similar Threads

  1. Far Cry 3
    By damngoodman999 in forum Gamerz
    Replies: 1212
    Last Post: 09-04-2013, 03:08 PM
  2. HTC Incredible S @ 18K
    By TheLetterD in forum Mobiles and Tablets
    Replies: 5
    Last Post: 04-04-2012, 07:41 PM
  3. HTC Incredible S Or ??
    By willymind in forum Mobiles and Tablets
    Replies: 15
    Last Post: 02-07-2011, 11:38 AM
  4. Incredible S vs Xperia Arc
    By sanithkk81 in forum Mobiles and Tablets
    Replies: 14
    Last Post: 14-05-2011, 05:23 PM
  5. Incredible Speeds
    By pushkar in forum Chit-Chat
    Replies: 17
    Last Post: 12-12-2008, 02:59 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Close