C++ Help Needed

lexias

Senior Member
Joined
Mar 31, 2012
Messages
1,605
Reaction score
0
I think for people whom can do each assignment on their own, it's all the merrier. In fact, if each student has own discipline in need no help to figure this out, or ask specific questions on understanding the concepts and principles towards the answer of any assignment, one will learn more and be a better person.

However unfortunately, seems like you wouldn't find a lot of such kind of students around. Rather than giving answers, it will be seemingly a good attempt to guide them along the way, make them think more, hopefully.

For really good students, you wouldn't have them asking questions in the open because they take it strongly in their pride to get things done themselves.

:)
yea pretty much,having a hard time trying to figure out on my side how to count occurrence with java code..
Just a qns, is it possible to do it without using arrays for java?
i take small pride :)
 

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,547
Reaction score
1,301
yea pretty much,having a hard time trying to figure out on my side how to count occurrence with java code..
Just a qns, is it possible to do it without using arrays for java?
i take small pride :)

Yes, you can use various methods to store data, basically are different data structures :)

If you are not using arrays, try linked-list, trees, hash tables/maps (mostly implemented using arrays or trees).

Even recursive functions have storage capacity for each local variables declared, which is effectively stored in the thread stack for each invocation.

Code:
void func(int s) {
  int a;
  // do something and store in "a"
  if (s > 0) fund(s - 1);
}

If I will to invoke the first iteration of "func" using s = 10, at the 10th recursive call, there will be a total of 10 "a" variables. Recursive functions are elegant for counting if you know how :)
 

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,547
Reaction score
1,301
im currently stuck at the last part of question 4, i do not know how to push the array, i tried putting 99==insertNumbers[position] or insertNumers[position]==99 but both methods still show the original random number of that particular array, please help. here is my code

Below is my answer to you on how "pushing" of the relevant array elements to the right. Think about the operation in the diagram. Think about how you will do it 1 step at a time if your brain is functioning like a computer. Break down the steps to accomplish "pushing" the element to the right into simple operation.

My hint to you is, "pushing" is actually a wrong metaphor to the operation, it should be called "pulling"

Shift the array before you place "99" into the array.

2yu0f0x.png
 

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,547
Reaction score
1,301
alright, thanks for putting in the effort to explain it to me, i will try it, do take note that i will not reply as quickly again, and question 5 is hell according to some of my classmates haha

:) Take your time, I'm not going anywhere.
 
Important Forum Advisory Note
This forum is moderated by volunteer moderators who will react only to members' feedback on posts. Moderators are not employees or representatives of HWZ Forums. Forum members and moderators are responsible for their own posts. Please refer to our Community Guidelines and Standards and Terms and Conditions for more information.
Top