Results 1 to 4 of 4

Thread: Dynamic 2D arrays

  1. #1
    Administrator asylu3's Avatar
    Join Date
    Jun 2000
    Location
    Thailand
    Posts
    3,557


    Dynamic 2D arrays

    [src]
    #include< iostream.h >

    void main()
    {
    int **a,m,n; // double pointer for 2d arry

    cout<<" n enter the number of rows and coloums for matrix:";
    cin>>m>>n;

    a=new int *[m]; // dynamic allocation of pointers array for column
    for(int i=0;i<m;i++)
    a=new int [n]; // dynamic allocation of coloums for each rows

    cout<<"n enter the elements:";
    for(i=0;i<m;i++)
    for(int j=0;j<n;j++)
    cin>>a[j];

    cout<<"n the elements r:";
    for(i=0;i<m;i++)
    {
    for(int j=0;j<n;j++)
    cout<<a[j]<<" ";
    cout<<"n";
    }

    }
    [/src]

  2. #2
    BingLi224
    Guest


    Re: Dynamic 2D arrays

    แล้วตอน delete ทำยังไงครับ ???

  3. #3
    Senior Member
    Join Date
    Jul 2004
    Location
    Bangkok
    Posts
    187


    Re: Dynamic 2D arrays

    for (int j = 0; j < m; ++j) delete[] a[j];
    delete[] a;

  4. #4
    Administrator asylu3's Avatar
    Join Date
    Jun 2000
    Location
    Thailand
    Posts
    3,557


    Re: Dynamic 2D arrays

    โอ้วโดนตัดหน้าซะแล้วว

Similar Threads

  1. Dynamic DNS คืออะไร มาดูกัน
    By snobots in forum ทิปหรือเคล็ดลับการคอมพิวเตอร์ต่างๆ
    Replies: 0
    Last Post: 02-05-2010, 02:15 PM
  2. ~ Dynamic Learning Dreamweaver CS3 ~
    By hooligan in forum E-Book, Video หรือบทความทั่วไปด้าน Computer
    Replies: 0
    Last Post: 30-03-2009, 11:13 AM
  3. Dynamic web คืออะไร
    By crusader8054 in forum PHP,ASP,Javascript, Html
    Replies: 0
    Last Post: 01-06-2007, 11:25 AM
  4. Dynamic Web Page คืออะไร?
    By attaporn11 in forum PHP,ASP,Javascript, Html
    Replies: 1
    Last Post: 03-02-2007, 04:32 PM
  5. Dynamic programming
    By newsbot in forum CS CE CPE Community
    Replies: 0
    Last Post: 17-06-2004, 09:14 PM

Members who have read this thread : 0

Actions : (View-Readers)

There are no names to display.

Tags for this Thread

Posting Permissions

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