Can anyone help ?

A certain engineering apparatus is controlled by the input of successive numbers (integers> 0). If there is a run of the same number, the apparatus can optimize its performance.
Hence we would like process the data and report it to the machine using an optimized format
that indicates all runs. Your program will read in a sequence of numbers terminated by a 0
(called a batch) and then print out each run of numbers in the batch in the form (nm) where
m is the number repeated n times. Note that a run can consist of just a single number.

For example, input data of the single batch
20 20 20 20 20 20 20 20 50 50 50 50 60 60 60 60 60 20 30 30 30 30 30 0
would produce the following (nm) pairs
(820)(450)(560)(120)(5*30)
outputted on a single line.

Write a C program that will input an unspecied number of batches and report each batch
of runs in the manner discussed above, one batch per line. An input of -1 should terminate
all batches. For example, the input

2 2 2 5 123456 0
10 10 10 10 20 20 20 20 0
0
0
5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 0
-1
would produce the following output:
(23)(51)(1234561)
(10
4)(204)
(5
15)

Input to your program must come from standard input; do not use any prompts for input.
Each outputted batch should be printed on a line by itself exactly in the manner shown
above (and in the sample run below). Empty batches are allowed. Do not output any of the
control characters (i.e. the 0 or -1).
1

what do u want?? the whole code…dont expect full codes…pls put in some effort and atleast start…if u get stuck somewhere then ask. …:slight_smile:

1 Like