Search found 3 matches

by shiggy
Fri Aug 01, 2008 8:52 pm
Forum: C++
Topic: Dynamic allocation of matrix?
Replies: 5
Views: 3556

Re: Dynamic allocation of matrix?

You could write a function like:


int** create_2d_array(int rows, int cols)
{
int** array = new int*[rows];

for (int i = 0; i < rows; i++)
array[i] = new int[cols];

return array;
}

//...

int** array = create_2d_array(5,5);
array[0][0] = 1;
array[3][4] = 1;
//etc


Replacing int with ...
by shiggy
Thu Jan 31, 2008 7:00 am
Forum: C++
Topic: sorting using algorithm
Replies: 1
Views: 2005

sorting using algorithm

Is this the correct way to use sort?


//include files (iostream, algorithm, vector, etc.)
class C
{
//...stuff
bool operator < (const C& r) const
{
if (some_attribute < r.some_attribute)
return true;
else
return false;
}
}

int main()
{
///
vector<C> units;
load_units(units);
sort ...
by shiggy
Sun Jan 20, 2008 9:21 am
Forum: Volume 1 (100-199)
Topic: 105 - The Skyline Problem
Replies: 160
Views: 51365

Like some people said in other threads, I my AC programs gives
1 11 3 13 9 0 12 17 16 3 19 18 22 3 23 29 0
for the test case stated in the problem.

I solved it by printing the x,y coordinates of the corners in the generated image, which isn't what is described by the problem but it gives an ...

Go to advanced search