473,385 Members | 1,324 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,385 software developers and data experts.

storing 2d array

hi,

I have a program which creates a list of x and y values from a calculation.
e.g sx sy
10 20
15 67
20 70

Iam trying to store these into an array each time it calculates a value for x and y.

declare:
Expand|Select|Wrap|Line Numbers
  1. double graph[7][7]
my code:
Expand|Select|Wrap|Line Numbers
  1. for (int c=0; c<= sy; c++)
  2. {
  3.   for (int x=0; x<=sx; x++)
  4.   {
  5.  
  6.     graph[x][c]=' ';
  7.     cout << graph+1 << endl;
  8. ...
am i going about this the complete wrong way?
do i need for loops to store the results?
May 3 '07 #1
3 1936
Hi ,

Instead of arrays, you can use vectors and pairs.
Something like the below
::Code removed per Posting Guidelines::
Regards
Prasannaa
May 4 '07 #2
AdrianH
1,251 Expert 1GB
am i going about this the complete wrong way?
do i need for loops to store the results?
I'm not sure, your question is a bit vauge. All I'm getting so far is you have a list of number pairs, and you want to do something with it. What exactly are you wanting to do?


Adrian
May 4 '07 #3
Savage
1,764 Expert 1GB
hi,

I have a program which creates a list of x and y values from a calculation.
e.g sx sy
10 20
15 67
20 70

Iam trying to store these into an array each time it calculates a value for x and y.

declare:
Expand|Select|Wrap|Line Numbers
  1. double graph[7][7]
my code:
Expand|Select|Wrap|Line Numbers
  1. for (int c=0; c<= sy; c++)
  2. {
  3.   for (int x=0; x<=sx; x++)
  4.   {
  5.  
  6.     graph[x][c]=' ';
  7.     cout << graph+1 << endl;
  8. ...
am i going about this the complete wrong way?
do i need for loops to store the results?
And how exactly is ur programm calculating x and y?

Have u maked a function?

If u have u can make ur function to return struct that contains x and y and then asign those to ur 2d array.

If u have not created a function than this pseudo code should do it:

Expand|Select|Wrap|Line Numbers
  1. FOR first counter which will start at 0 and finish at last row first counter increases
  2. {
  3.      FOR secound counter which will also start as 0 and finish when lower than 
  4.      2 becasue there are two variables x and y secound counter increases too
  5.      {
  6.          graph[i][j]= is ur x variable when j=0 or y variable when j=1(this piece u 
  7.                           can figure out by ur self)
  8.  
  9.          //Legend: i-first counter
  10.                        j-secound counter.
  11.  
  12.       }
  13. }

And also graph in ur case should be declared as graph[number of rows][2];

Savage
May 4 '07 #4

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

Similar topics

15
by: Tor Erik Sønvisen | last post by:
Hi I need a time and space efficient way of storing up to 6 million bits. Time efficency is more important then space efficency as I'm going to do searches through the bit-set. regards tores
3
by: Brad | last post by:
I am storing an array which contains about a dozen chracter items to a Session variable. Later, I need to use this array so I am doing the following: Dim eventTypes As String() =...
7
by: paladin.rithe | last post by:
Is it possible to store classes in an array? I am fairly new to PHP, and haven't found anything either way yet. I have a program that where you can have multiple notes attached to a ticket, which...
22
by: guitarromantic | last post by:
Hey everyone, I run a site with staff-submitted reviews, and most of them are written by one author. However, we also do "multiple" reviews. Up until now I just had a userid for a 'Multiple'...
2
by: gh | last post by:
Hi, I have a string variable which contains n number of comma delimited elements and I would like to store each element into an array but I could not figure how to do it. for example,...
6
by: Kyle Teague | last post by:
What would give better performance, serializing a multidimensional array and storing it in a single entry in a table or storing each element of the array in a separate table and associating the...
3
by: ArmsTom | last post by:
I was using structures to store information read from a file. That was working fine for me, but then I read that anything stored in a structure is added to the stack and not the heap. So, I made...
20
by: Martin Jørgensen | last post by:
Hi, I'm reading a number of double values from a file. It's a 2D-array: 1 2 3 4 5 6 7 ------------- 1 3.2 2 0 2.1 3 9.3 4
1
by: Miesha.James | last post by:
Hello, I'm trying to rewrite visual c++ code into visual c++ .NET code and I've run across a problem with storing objects into a list. Here;s an example of the code I have: ref struct...
10
by: deciacco | last post by:
I'm writing a command line utility to move some files. I'm dealing with thousands of files and I was wondering if anyone had any suggestions. This is what I have currently: $arrayVirtualFile =...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.