473,322 Members | 1,473 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

2D array fill

hi all I need to write a function that fill the array with the numbers 1 to 54 in ascending order going from left to right then top to bottom. Therefore 1 will be in the top left hand corner, 6 in the top right hand corner, 49 in the bottom left corner
and 54 in the bottom right hand corner. I know how to fill left to right with one for loop but how do I do it with a 2D array??

thanks again
Mar 28 '07 #1
1 2351
arne
315 Expert 100+
hi all I need to write a function that fill the array with the numbers 1 to 54 in ascending order going from left to right then top to bottom. Therefore 1 will be in the top left hand corner, 6 in the top right hand corner, 49 in the bottom left corner
and 54 in the bottom right hand corner. I know how to fill left to right with one for loop but how do I do it with a 2D array??

thanks again
See if this works
Expand|Select|Wrap|Line Numbers
  1.         int i, array[9][6];
  2.         for (i=1; i<55; i++) {
  3.                 *(*array + i - 1) = i;
  4.         }
  5.  
Mar 28 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Peter Rooney | last post by:
Hi, I have 24 checkboxes all with the same naming convention, each box has a value ranging from 1 to 23, what I need to do is fill in the gaps with a 0 value where the user doesn't select a...
5
by: Fabio Papa | last post by:
Hi, I am fairly new to programming and and even newer to dotnet. I appoligise in advance if this is a dumb questions, and I would appreciate if you could answer it anyways. :) I am writing a...
12
by: JKop | last post by:
template<class T> inline T& NthArrayMember( T & (array),size_t i) { return array; } template<class T> inline const T& NthArrayMember( const T & (array),size_t i) { return array;
18
by: laclac01 | last post by:
Is there a way to pass a 2d array to a function in c++ with out having to specifiy the number of elements in the array. Here is an example #include<iostream> using namespace std; int...
7
by: ritchie | last post by:
Hi all, I am new to this group and I have question that you may be able to help me with. I am trying to learn C but am currently stuck on this. First of all, I have a function for each sort...
14
by: romayankin | last post by:
Hello All, I'm writing cross-platform code so i'm bound to standards. Here is the code I have: ~~~~~~~~~~~~~~~~~~ double **mx = new double*; for(int i = 0; i < col - 1; i++) { mx = new...
4
by: mathieu | last post by:
Hello, I would like implement a nice way to work around the array of references issue in C++. What do usually people do ? Do you maintain a separate factory/pool of elements as part of the API ?...
11
by: Lance | last post by:
Hi all, I've got a some structures defined as ////// <StructLayout(LayoutKind.Sequential)Public Structure GM_LayerInfo_t Public mDescription As String Public mNativeRect As GM_Rectangle_t...
10
by: SM | last post by:
Hello I'm trying to create a multi dimensional array in JavaScript, but after some reading i still can't figure out how to apply it to my model. Here it is: I have a list A and for each item...
1
by: Puddle | last post by:
Hi everyone, I'd just like to preface by saying any input or direction in this would be very much appreciated; i've been working on this endlessly and can't figure out what's going wrong. I'm...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.