----
Type: Posts; User: bot
----
The first thing you should do is to have a consistent style of indentation. You can read more about indentation in programming here:
Indenting C Programs
The Only Correct Indent Style |...
I wouldn't call myself an experienced programmer but I would suggest to break down the complex task into a series of simpler problems. For example you could implement the 16 slots or whatever the...
This stack could be dynamically allocated (with malloc()) or be fixed which is viable as you know that there will be no more than 8 players. For a fixed stack, you could let the slots be an 8 levels...
Yes, I too would rather work with vectors and arrays directly myself. If someone somehow however would want to maintain a clear association between each camel color and field, my suggestion above...
I think all those if statements in post #6 could altogether be replaced with the following lines of code:
const *char[] szykKolorowy = { "niebieska", "zielona", "pomaranczowa",
...
I find it hard to understand what is your question. You have an already half way written program, all that remains is to complete it. The char l doesn't contain all the letters of the aleph-bet and...
But if the program doesn't clean up after itself, won't the allocated memory stay allocated even after the program terminates? I have a (biological) memory that memory that wasn't freed will remain...
The time measured comes as reported by the website (kattis.com) so I would assume that they use proper tools to measure the time to execute. Perhaps it is an average value of a larger number of runs....
To begin with, I want to say thank you to all people who have helped me with issues that I had with c programming. That is a learning journey that I'm undertaking. I'm trying to be playful and...
Interesting, so it isn't that the dynamically allocated memory itself is slower than "statically" allocated memory at the beginning of the program, but the calls to malloc(), calloc() and realloc()...
I really feel like an idiot now, thank you, it works!
So changing from
void pushQueue(element) {
...
}
to
void pushQueue(Pixel element) {
I've been experimenting with different types of "queues" of fixed size which I have shown in a previous thread. Now however, I want to design a proper queue of unspecified length that allocates and...
Of course, I probably went through the code at least 15 times without seeing it! I knew that it should start from 1 so I completely overlooked it. Thank you for that, this is a little embarrassing I...
I didn't know this thing with sqeuence points was such an issue. I have always assumed that when coding say
int x = 5, y = 6;
int z = x++ + y++;
then it means that the compiler should first...
If you interpret my response as snarky, then I apologize. That was not my intention and your help has been much appreciated. I will look into your suggestions in a bit.
Yes when queueLength...
Sorry but it doesn't compile at all on any platform with "worldArray[i] = worldArray[i - 1] + NCOLS;", I hope you are aware that this is an array of booleans, not integers. I had a little hope to...
I think you should use
worldArray[i] = worldArray[i - 1 + NCOLS];instead of
worldArray[i] = worldArray[i - 1] + NCOLS;
As I understand, 2-dimensional arrays are stored as a 1-dimensional...
Yes, I actually am in the process of optimizing the code. Something in the program that I was thinking that was using CPU cycles is the requeue() function. I was thinking that shuffling data back and...
Yes, yes, that solved my problem and the website accepted my program. Thank you! Tank you!
It also runs fine now in the Windows environment.
I find it rather strange that it doesn't crash...
See page 9 of the following document for problem description:
http://challenge.csc.kth.se/2011/problems.pdf
The variables nRows and nCols are the number of rows and columns of the map that is fed into the program. I let the program surround the the map with a border of 0's. So the actual matrix has...
I'm unable to troubleshoot with the debugger because I don't have access to the data that gives rise to the exception. The program is compiled and tested on a website and all you get is whether it...
The following program is supposed to solve the coast problem:
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
bool **worldArray;
bool **removalMask;
Ok, just to make a clearer illustration of the issue:
int *array1 = new[iSize1], *array2 = new[iSize2];
...
delete[] array1, array2;