URI Online Judge | 1174
Array Selection I
In this problem, your task is to read an array A[100]. At the end, print all array positions that store a number less or equal to 10 and the number stored in that position.
Input
The input contains 100 numbers. Each number can be integer, floating-point number, positive or negative.
Output
For each number of the array that is equal to 10 or less, print "A [i] = x", where i is the position of the array and x is the number stored in the position, with one digit after the decimal point.
Input Sample | Output Sample |
0 -5 63 -8.5 ... | A[0] = 0.0 A[1] = -5.0 A[3] = -8.5 ... |
Solution:
#include <stdio.h> int main() { double ar[100]; int i; for(i=0; i<=99; i++) scanf("%lf", &ar[i]); for(i=0; i<=99; i++) { if(ar[i]<=10.0) printf("A[%d] = %.1lf\n",i, ar[i]); } return 0; } |
Post a Comment
0Comments