Timus Problem 1001 (Reverse Root) Solution

Timus Problem Solution

Timus Problem 1001(Reverse Root) :

Reverse Root is a mathematical problem.

To read details : http://acm.timus.ru/problem.aspx?space=1&num=1001

Proplem description: This is a straightforward problem.Just do square root.

Problem Solution:

#include <stdio.h>

#include <math.h>

int main()

{

double a[100],b[100];

int i,j,swap,n;

scanf("%d",&n);

for(i=0;i<n;i++){

scanf("%lf",&a[100]);

}

for(i=0;i<n;i++){

b[j]=sqrt(a[i]);

j++;}

for(i=0;i<j;i++){

    for(j=0;j<i;j++){

        if(b[j]==b[j+1]||b[j]>b[j+1]||b[j]<b[j+1]){

        swap=b[j];

        b[j]=b[j+1];

        b[j+1]=swap;}

    }

}

for(i=0;i<n;i++){

    printf("%.4lf\n",b[i]);

}

return 0;

}

0 Comments

You may find interest following article

Complete Guide: Create Laravel Project in Docker Without Local Dependencies

Create Laravel Project Through Docker — No Need to Install PHP, MySQL, or Apache on Your Local Machine In this tutorial, I’ll show you how to create and run a full Laravel project using Docker containers. That means you won’t have to install PHP, MySQL, or Apache locally on your computer. By the end of this guide, you’ll have a fully functional Laravel development...