Question:
Can anybody help me write a C program on arrays and functions?
Darrell
2011-11-21 20:32:47 UTC
Coach Whytlaw, the local swim coach has a problem he wants you to help solve.
The timing system at the pool gives him a fi le containing information about
each race. The fi le contains:
The number of races in the file, on a line by itself.
For each race, there is a line in the fi le containing the following:
Information about the pool as follows: Whether the Pool is Long course (L)
or Short Corse (S) Whether the Pool is Meters (M) or Yards (Y)
Information about the length of the race, in appropriate units. The shortest
race is 50 yards or meters and the longest race is 1650 yards or meters.
The time (in seconds) for each length of the pool (A length of the pool in a
long corse pool is 50 meters or yards. A length of the pool in a short corse pool
is 25 meters or yards).
The coach would like you to use the times to do some analysis on the races.
Here is the information he would like:
 The total length of time it took to swim the race (displayed in minutes
and seconds).
 The time for each 50 yards in the race (displayed in minutes and seconds).
 For races longer than 100 yards or meters, the time of each multiple of
100 yards or meters.
 The fastest 50 yards or meters, by number (1st 50, 2nd 50,etc)
 the slowest 50 yards or meters, by number (1st 50, 2nd 50,etc)
 the fastest 100 yards or meters, by number (1st 100, 2nd 100,etc)
 the slowest 100 yards or meters, by number (1st 100, 2nd 100,etc)
 Wheter or not the race was a negative split (was the fi rst half of the race
slower than the second half).

An Example input le appears as follows:
3
LM 200 32.52 34.88 39.22 37.20
SM 100 12.52 14.88 13.22 13.20
SY 50 12.20 12.50
The output produced from the above should be:
Race 1: Long Course 200 Meters:
Total Time: 2:23.82
1st 50m: 32.52
2nd 50m: 34.88
3rd 50m: 39.22
4th 50m: 37.20
1st 100m: 1:07.40
2nd 100m: 1:16.42
Fastest 50: 1st
Slowest 50: 3rd
Fastest 100: 1st
Slowest 100: 2nd
Negative Split: No
Race 2: Short Corse 100 Meters:
Total Time: 53.82
1st 50m: 27.4
2nd 50m: 26.42
1st 100m: 53.82
Fastest 50: 2nd
Slowest 50: 1st
Fastest 100: 1st
Slowest 100: 1st
Negative Split: Yes
Race 3: Short Corse 50 Yards:
Total Time: 24.70
1st 50y: 24.70
Fastest 50: 1st
Slowest 50: 1st
Negative Split: No
Three answers:
arrocha
2016-10-17 15:43:50 UTC
you'll have the skill to position in rigidity the printf() clone in a great number of procedures.. One approach is to employ putchar() procedure... now you'll have the skill to be confusing over a thanks to pass random quantity of arguments to our new function (allow that is named myprint()).. In C we may have the skill to jot down amenities which takes some quantity of arguments... how?? int myprint(int itemsToPrint, char [] type,...) So now prototype is executed.. We now purely ought to sparkling up the arguments which will be to be printed.. For this we ought to apply few macros supplied by way of technique of between the C implementations.. utilising those macros we may have the skill to get admission to the arguments exceeded to our new function(i do no longer save in concepts there stumble on effectively...) Even printf/scanf makes use of those macro calls.. In our function first argument is the quantity of arguments to be printed.. 2d argument is someone array that ought to contain the kind of arguments which will be to be printed interior the order of seem interior the function call... now if you're to print someone / man or woman string using putchar is reachable.... if you're about to print a flow/int and so on.. then convert them to man or woman array and use puthar to print man or woman characters ...
Bishow
2011-11-21 22:29:13 UTC
in c

int a[5];

for (i=0;i<5;i++)

{

printf("%d",a):

}
free_slyscafe
2011-11-21 20:39:44 UTC
Do your own homework.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...