Solved

Jagged Array in C++

Posted on 2003-11-06
3
1,348 Views
Last Modified: 2012-06-22
Create a jagged array named foo in C++.  Row 0 will contain the integers 1,2; row 1 will contain 4,3,3,0; and row 2 will contain 5,6.
0
Comment
Question by:Xirom431
3 Comments
 
LVL 11

Expert Comment

by:bcladd
ID: 9696560
This sounds a lot like homework. It is agains EE policy for members to do homework OR for members to request solutions to homework. Has something to do the "academic honesty".

That said, what do you know how to do in C++? Show us your code so far and we would be happy to answer your specific questions.

-bcl
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 9696715
Agree.  Who is your instructor?  Foo was the favorite example variable of an teaching buddy of mine.

mlmcc
0
 
LVL 5

Accepted Solution

by:
waelothman earned 100 total points
ID: 9698857
if i understand write you want 2 dim. array without fixing the dimention
contain 3 rows the 1st row contain 4 elements and the second contain 4 elements and the 3ed conatin 2 elements
this can be done by creating array of pointer as

int *  foo[3];
foo[0] = new int[2];
foo[0][0]=1;foo[0][1]=2;
foo[1] = new int[4];
foo[1][0]=4;foo[1][1]=4;foo[1][2]=4;foo[1][3]=0;
foo[2] = new int[2];
foo[2][0]=5;foo[2][1]=6;

but i want to add if this is homework try to know why we think like that the solution itself not the problem ,but the problem always in the way of thinking
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question