Algorithm


Problem Name: beecrowd | 1174

Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/1174

Array Selection I

 

Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

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
...

 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming


#include <iostream>
#include <iomanip>
using namespace std;
int main(){
    double lista[100];
    double k;
    for(int i = 0; i  <  100; i++){
        cin >> k;
        lista[i] = k; 
    }
    for(int i = 0; i  <  100; i++){
        if(lista[i] <= 10){
            cout << fixed << setprecision(1>;
            cout << "A[" << i << "] = " << lista[i] << "\n";
        }
    }
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
0 -5 63 -8.5 ...

Output

x
+
cmd
A[0] = 0.0 A[1] = -5.0 A[3] = -8.5 ...

#2 Code Example with Javascript Programming

Code - Javascript Programming


const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const lines = input.split('\n');

let lista = [];
for(var i = 0; i  <  100; i++){
    let o = parseFloat(lines.shift());
    lista.push(o);
}
for(var i = 0; i  <  100; i++){
    if(lista[i] <= 10){
        console.log(`A[${i}] = ${(lista[i]).toFixed(1)}`>;
    }
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
0 -5 63 -8.5 ...

Output

x
+
cmd
A[0] = 0.0 A[1] = -5.0 A[3] = -8.5 ...

#3 Code Example with Python Programming

Code - Python Programming


lista = []
for i in range(0, 100):
    lista+=[float(input())]
for i in range(0, 100):
    if lista[i] <= 10:
        print(f'A[{i}] = {lista[i]:.1f}')
Copy The Code & Try With Live Editor

Input

x
+
cmd
0 -5 63 -8.5 ...

Output

x
+
cmd
A[0] = 0.0 A[1] = -5.0 A[3] = -8.5 ...
Advertisements

Demonstration


Previous
#1173 Beecrowd Online Judge Solution 1173 Array fill I Solution in C++, Java, Js and Python
Next
#1175 Beecrowd Online Judge Solution 1175 Array change I Solution in C++, Java, Js and Python