Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,043 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,556 people online right now. Registration is fast and FREE... Join Now!




Help with output

 
Reply to this topicStart new topic

Help with output

dwd3773
5 Aug, 2008 - 07:52 AM
Post #1

D.I.C Head
**

Joined: 9 Feb, 2008
Posts: 103



Thanked: 1 times
My Contributions
Need help figuring the out come of these problems.

CODE

intf(int arr[], int n)
{
    int i;
    int maxct=0;
    int tValue=0;

    for(i=1; i<n; i++)
    
    if(arr[i] == tValue)
        ct++;
    else
    {
        if(maxct<ct)
                maxct=ct;
                ct=1;
        tValue = arr[i];
    }
    
    return maxct;
}
          


For intArr[] = {2,3,3,6,6,8,9,9,11,12,12}
return value from f(intArr, 12) is:

For intArr[] = {4,7,7,10,10,15,20,20,20,21}
return value from f(intArr, 11) is:

User is offlineProfile CardPM
+Quote Post

NickDMax
RE: Help With Output
5 Aug, 2008 - 08:14 AM
Post #2

2B||!2B
Group Icon

Joined: 18 Feb, 2007
Posts: 2,858



Thanked: 49 times
Dream Kudos: 550
My Contributions
can you please describe the problem...
User is offlineProfile CardPM
+Quote Post

dwd3773
RE: Help With Output
5 Aug, 2008 - 08:25 AM
Post #3

D.I.C Head
**

Joined: 9 Feb, 2008
Posts: 103



Thanked: 1 times
My Contributions
Well thats all I got as far as information on the problem. The computer with my programmer on it is busted at the monent so thats why I'm asking. Its actually a 2 part problem, the two sets of intArr[] at the bottom on the previous post, are supposed to be used to determine the output. The problem is presented to me as a multiple choice question and the choices of output are as follows:

a). 2, 4
cool.gif. 3, 4
c). 3, 7
d). 2, 7
User is offlineProfile CardPM
+Quote Post

dwd3773
RE: Help With Output
5 Aug, 2008 - 09:05 AM
Post #4

D.I.C Head
**

Joined: 9 Feb, 2008
Posts: 103



Thanked: 1 times
My Contributions
cool.gif.
User is offlineProfile CardPM
+Quote Post

NickDMax
RE: Help With Output
5 Aug, 2008 - 09:30 AM
Post #5

2B||!2B
Group Icon

Joined: 18 Feb, 2007
Posts: 2,858



Thanked: 49 times
Dream Kudos: 550
My Contributions
well since you still have not really described what the function does or what is wrong with it I don't know how to help.

I did notice that you didn't declare the variable "ct".
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 04:44PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month