1 / 5
Sep 2014

Hello! How are you, I am here to ask about some tips.

-How do you improve your capacity of understanding the problem, and making a solution to that problem (I mean in general, SPOJ for ex. those who are really challenging)

-What are the best technics to transcribe this problem-->solution to the specified lenguage (I mean, graphics, comments, etc)

OFFQ: I have a big problem with arrays + pointers + post/prefixes

For example:

for(int i = 0; i < 10; i++){
++myArr[i]; // I do not get what is done here
}

Thank you very much!
Delsh

Practice and asking questions.

Not sure what you are asking here.

++myArr[i]; means to increment the value at myArr[i] by 1. It is equivalent to myArr[i] = myArr[i] + 1; Also equivalent is myArr[i]++;

The difference between myArr[i]++; and ++myArr[i]; is the timing of when the increment occurs.

#include <cstdio>
using namespace std;
int main() {
	int t = 5;
	printf("Prefix:\n");
	while(--t > 0)
		printf("%d\n", t);
	t = 5;
	printf("Suffix:\n");
	while(t-- > 0)
		printf("%d\n", t);
}

Thank you very much leppy, you are always there!

So if i have myArray[1] lets say it is 5 (myArray[1]=5)
if we do ++myarray[1] it will start at 6 because it is already initialized?
and myArray[1]++ will be 6 after the operation is done?

Thanks Again,
Delsh

#include <cstdio>
using namespace std;
int main() {
	int myArray[15]; 
	myArray[1] = 5;
	printf("%d\n", myArray[1]);
	++myArray[1];
	printf("%d\n", myArray[1]);
	myArray[1] = 5;
	myArray[1]++;
	printf("%d\n", myArray[1]);
}

Output:

5
6
6