Beecrowd 1178 Array Fill III Solution in C, C++|| Beecrowd 1178 || Free Code Center

Problem link

Beecrowd 1178 Array Fill III Solution in C, C++

Read a number X. Put this X at the first position of an array [100]. In each subsequent position (1 up to 99) put half of the number inserted at the previous position, according to the example below. Print all the vector N.

Input

The input contains a double-precision number with four decimal places.

Output

For each position of the array N print “N[i] = Y”, where i is the array position and Y is the number stored in that position. Each number of N[…] must be printed with 4 digits after the decimal point.

Input SampleOutput Sample
200.0000N[0] = 200.0000
N[1] = 100.0000
N[2] = 50.0000
N[3] = 25.0000
N[4] = 12.5000

Beecrowd 1178 Array Fill III Solution in C++

#include<iostream>
#include <iomanip>

using namespace std;
int main()
{
   double a;
   cin>>a;
   for(int i=0;i<100;i++){

               cout<<"N["<<i<<"] = "<<setprecision(4)<<fixed<<a<<endl;

         a=a/2.0;
             //  cout<<"N["<<i<<"]"<<setprecision(4)<<fixed<<a<<endl;


   }
   return 0;
}

Next problems:URI Bee Crowd 1095: How to Solve the Sequence IJ-1 Problem

1 thought on “Beecrowd 1178 Array Fill III Solution in C, C++|| Beecrowd 1178 || Free Code Center”

  1. Pingback: Uri 1080 Solution || BEE 1080 || Beecrowd1080 Highest And Position » Free Code Center

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top
NEW TOXIC ROCKET CYCLE DECK in Clash Royale 2023 Best Deck in Clash Royale Best Deck for Arena 8 in Clash Royale Best Hog deck for Pro players Best Clash Royale Deck