URAL 1001. Reverse root

本文介绍了一个使用静态数组存储并计算输入数值平方根的C++程序示例。该程序读取一系列浮点数,并使用标准库函数`sqrt`计算每个数的平方根,最后将结果按接收顺序逆序输出。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

 

Use static Array to hold all the square root values and print them all:

 the AC result is not so good: 0.42s and 12xxKB, maybe I should implement the sqrt myself?

#include  < cstdio >
#include 
< iostream >
#include 
< cmath >

using   namespace  std;

#define  MAXNUM 700000

double  dList[MAXNUM];

void  main()
{
    
int  i  =   0 ;
    
    
double  dCur  =   0.0 ;

    
while (scanf( " %lf " & dCur)  !=  EOF)
    {
        dList[i] 
=  sqrt(dCur);
        
++ i;        
    }

    
while (i > 0 )
    {
        printf(
" %.4f " , dList[i - 1 ]);
        
-- i;
    }
}

 

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值