Let's say I have
double a[N][M] = { .......};
How to transform a into a 2D vector
vector< vector<double v
? 4 1151
But if you wanted that why would
you start off with a plain 2D array in the first place.
If you wanna initialize a 2D vector (12x2) with the following data:
-5, -5,
-5, 105,
105, 105,
105, -5,
60, -5,
60, 40,
70, 40,
70, 60,
30, 60,
30, 40,
40, 40,
40, -5,
How do you do that?
On Fri, 04 Apr 2008 11:43:10 -0700, xz wrote:
>But if you wanted that why would you start off with a plain 2D array in the first place.
If you wanna initialize a 2D vector (12x2) with the following data:
-5, -5,
-5, 105,
105, 105,
105, -5,
60, -5,
60, 40,
70, 40,
70, 60,
30, 60,
30, 40,
40, 40,
40, -5,
How do you do that?
int arr[2][2]={{-5,-5,},{-5,105}};
You can probably figure out the rest...
On Apr 4, 11:43*pm, xz <zhang.xi...@gmail.comwrote:
But if you wanted that why would
you start off with a plain 2D array in the first place.
If you wanna initialize a 2D vector (12x2) with the following data:
-5, * * -5,
-5, * * 105,
105, * *105,
105, * *-5,
60, * * -5,
60, * * 40,
70, * * 40,
70, * * 60,
30, * * 60,
30, * * 40,
40, * * 40,
40, * * -5,
How do you do that?
If that is the case, then why do you want to use a vector at all? Why
don't you work with the arrays only or something like boost:array?
vectors are not a complete replacement of arrays especially when
arrays know their size (and they don't grow) and elements at the time
of creation.
On Apr 5, 1:07 am, Abhishek Padmanabh <abhishek.padman...@gmail.com>
wrote:
On Apr 4, 11:43 pm, xz <zhang.xi...@gmail.comwrote:
But if you wanted that why would
you start off with a plain 2D array in the first place.
If you wanna initialize a 2D vector (12x2) with the following data:
-5, -5,
-5, 105,
105, 105,
105, -5,
60, -5,
60, 40,
70, 40,
70, 60,
30, 60,
30, 40,
40, 40,
40, -5,
How do you do that?
If that is the case, then why do you want to use a vector at all? Why
don't you work with the arrays only or something like boost:array?
vectors are not a complete replacement of arrays especially when
arrays know their size (and they don't grow) and elements at the time
of creation.
What if I want to use some function that reads vector instead of
array? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jiho Han |
last post by:
Suppose I have an xml fragment like:
<mother>
<child name="Bob" sex="M"/>
<child name="Jane" sex="F"/>
...
</mother>
If I wanted to replace the <mother> element to <father> element, what is...
|
by: Oliver Brausch |
last post by:
Hello,
have you ever heard about this MS-visual c compiler bug?
look at the small prog:
static int x=0;
int bit32() {
return ++x;
}
|
by: David Rogers |
last post by:
Is this sequence about as efficient as I can get for sometimes expanding an
array?
MyClass MyFunc()
{
MyClass result = new MyClass ;
{
// Do stuff that might possibly allocate an array...
|
by: Helge Jensen |
last post by:
I've got some data that has Set structure, that is membership, insert
and delete is fast (O(1), hashing). I can't find a System.Collections
interface that matches the operations naturally offered...
|
by: Jason Huang |
last post by:
Hi,
Would someone explain the following coding more detail for me? What's the
( ) for?
CurrentText = (TextBox)e.Item.Cells.Controls;
Thanks.
Jason
|
by: JRoughgarden |
last post by:
After a customer decides to buy a shopping list, there is generally a
need to store/insert one master record and a variable number of child
detail records, preferably all wrapped in a transaction....
|
by: calvert4rent |
last post by:
I need to some sort of data type that will hold a listing of ID's and
their counts/frequency. As I do some processing I get an ID back
which I need to store and keep an accurate count for how many...
|
by: darren |
last post by:
Hi
I have to write a multi-threaded program. I decided to take an OO
approach to it. I had the idea to wrap up all of the thread functions
in a mix-in class called Threadable. Then when an...
|
by: timor.super |
last post by:
Hi all,
Imagine I've an array of int :
int anArray = new int;
I want to extract all the integer that are superior to 500
I can do :
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |