so what i need to do is implement a code that will take the maximum number in a array and put it into another array. events[] is an array that contains numbers that was extracted from a file. Count is the number of numbers in the array events[ ] because i did not know how many numbers i was reading. numDays is also an array.eventNumD ays is the array for which i need to put the maximun number that numDays [] contains. but this is just not the any regular max number i need to copy. an example is the following:( note that i put dashes so you can see it better. but the number under th events[] is for events[]. and the number under numDays[] is for numDays.
events[]:contains----------------------numDays[] contains:
1----------------------------------------------1
1----------------------------------------------3
1----------------------------------------------2
2----------------------------------------------5
3----------------------------------------------1
3----------------------------------------------8
4----------------------------------------------4
6----------------------------------------------1
so the maximum number for events[] which contains the number 1 is 3 because 3 is greater that 1 or 2. The maximum number for event[] which contains the number 2 is 5. the maximum number for the event[] which contains the number 3 is 8. and so on. i hope you see what i have to do. maybe looking at my algorithm could help you realize what i need to do. anyway, this is too tricky for me, thus i turned to the c++ community. if there is any question ask.
for(int j=1;j<events[count-1];j++)
{
while(events[i]==j)
{
if (numDays[i]<numDays[i+1])
{
max=numDays[i+1];
}
i++;
}
eventNumDays[j]=max;
sum+=max;
max=0;
}
events[]:contains----------------------numDays[] contains:
1----------------------------------------------1
1----------------------------------------------3
1----------------------------------------------2
2----------------------------------------------5
3----------------------------------------------1
3----------------------------------------------8
4----------------------------------------------4
6----------------------------------------------1
so the maximum number for events[] which contains the number 1 is 3 because 3 is greater that 1 or 2. The maximum number for event[] which contains the number 2 is 5. the maximum number for the event[] which contains the number 3 is 8. and so on. i hope you see what i have to do. maybe looking at my algorithm could help you realize what i need to do. anyway, this is too tricky for me, thus i turned to the c++ community. if there is any question ask.
for(int j=1;j<events[count-1];j++)
{
while(events[i]==j)
{
if (numDays[i]<numDays[i+1])
{
max=numDays[i+1];
}
i++;
}
eventNumDays[j]=max;
sum+=max;
max=0;
}
Comment