Click here to Skip to main content
15,176,221 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
So first I need to input number using scanf separated by white space in to an array like this :
How many hours : 4
How many minutes for #1 : 10 6 55 
How many minutes for #2 : 30 50 60
How many minutes for #3: 60 30 50
How many minutes for #4 : 6 7 9
The finest hours are #2 and #3
The score is %d and the Standard Derivation is ___.

"Hours" input can be anything

Can only use stdio.h and math.h

What I have tried:

I have tried using while loop to find sum
to store in first array then calculate SD with
function command store in another array
but somehow it end up like this so I try to make it
Work at least finding sum of all minutes first.

How many minutes for #1: 1 2 3

How many minutes for #2:
How many minutes for #3:
How many minutes for #4: input able here

so it just skip from 1 to 4
not let me do input in #2 and #3

*I use scanf for most of input

This is finding sum part of the code
If (hours >= 1 && hours <= 60)
for(int i = 1; i < hours-1; ++I)
printf("\nHow many minutes for #1:",i);
scanf("%d", &minutes);
sum = minutes + sum;
array[I] = sum;
return 0;

Ok so I just add another loop inside the loop
To fix problem above now, but still can't figure out
How to find SD and printf when there are multiple
Maximum values

Full code :
Updated 4-Nov-20 22:15pm
CPallini 5-Nov-20 2:02am
You should state more clearly what are your actual requirements. For instance, do you need to compute the average and the standard deviation of each sequence? What makes #2 and #3 the 'finest hours'?
Kamkom Rifles 5-Nov-20 2:54am
The finest hours needs to have this quality:

- maximum values of sum(highest value)
- if there are more than one maximum sum, the lowest SD became the finest hours
- #2 and #3 are both equal in sum and S.D.

I need to compute Sum and Standard Derivation for every hours(sequence)

You must understand the Standard Derivationat first. You must choose whether you use the SD of one measurement or the SD of all data. Best is to seperate it.

tip: use structs for the data like:
struct Data {
 int index;
 int minutes1;
 int minutes2;
 int minutes3;
 double median;
 double SD;
} data;
Kamkom Rifles 5-Nov-20 2:50am
Well, the question asked to compare sum of the minutes first. If the sum is equal the one with lower SD will be the chosen value. Since there is N amount of hours (size between 1-60) create separated variables for every possible ways is possible but would consume a lot of resources.
Make a function that, given a sequence, computes its sum and standard deviation (it could return the two values in a struct).
Then call iteratively such a function over the input sequences, storing the returned values into an array. Eventually choose the 'finest sequences' based on the array values.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900