C Programming
C Programming
C Programming
Input
You are given the input in two lines:
Output
If there are k even numbers in the sequence, then output the kth
occurrence of even in the sequence. Otherwise, output a -1.
Sample Input
2
1 1 3 2 3 4 1 -1
Sample Output
4
Question 2
When you keep track of stock prices, or your weight during a diet
programme, the daily prices or weights fluctuate a lot. One way to
identify the general trend is to keep track of the average over the
last 3 days, for example. This technique often smooths out the
fluctuations, and makes the trend clearer. This technique is called
"moving average".
Output
------
You have to output the moving average of the sequence. The output
should be printed correct to one digit after the decimal.
Sample Input 1
--------------
70.8 70.9 71.2 70.7 70.2 -1
Sample Output 1
---------------
71.0 70.9 70.7
Question 3
A line of English text will be given, where words are separated by one
of the following symbols:
Each word may be separated from the next and the previous by one or
more of the following symbols. You have to count the number of words
in the sentence.
Note that to read the input, you have to read until the EOF symbol is
read, as in the following example.
int main()
{
int c;
c = getchar();
while ( c != EOF ) {
c = getchar();
}
return 0;
}
Output
------
The number of words in the line.
Sample Input
------------
This is a sentence, it has words separated by spaces and fullstops.
Sample Output
-------------
12