transpos

This is a discussion on transpos within the C++ Programming forums, part of the General Programming Boards category; help me please.what is wrong in this code? Code: #include<iostream> using namespace std; const int size=3; void read(int a[size][size]) { ...

  1. #1
    Registered User
    Join Date
    Mar 2013
    Location
    iran
    Posts
    2

    Post transpos

    help me please.what is wrong in this code?



    Code:
    
    #include<iostream>
    using namespace std;
    const int size=3;                        
    void read(int a[size][size])
    {
    cout<<"enter"<<size*size<<"numbers"<<size<<"rows"<<endl; 
    for(int i=0;i<size;i++){
    cout<< "row"<<i<<":";
    for(int j=0;j<size;j++)
    cin>>a[i][j];
    }}
    void trans(int at[size][size],int a[size][size])
    {
    int i,j;
    at[j][i]=a[i][j];
    for(int i=0;i<size;i++){
    for(int j=0;j<size;j++){
    cout<< "radif"<<j<<":";
    cout<<at[j][i];
    }}
    cout<<endl;
    }
    int main()
    {
    int a[3][3],at[3][3];
    read(a);
    trans(a,at);
    trans(a,at);
    return 0;
    }

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,614
    It's really hard to see when you don't indent properly.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,548
    Also here, but not noticeably any improvement.
    problem in Program to find Transpose of Given Square Matrix

    @nazanin.padekan
    Fix the indentation, then post it in your original thread.
    This is closed.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21