资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

1001.ReverseRoot-创新互联

1001. Reverse Root

创新互联专注于册亨企业网站建设,自适应网站建设,商城网站制作。册亨网站建设公司,为册亨等地区提供建站服务。全流程按需设计网站,专业设计,全程项目跟踪,创新互联专业和态度为您提供的服务

Time limit: 2.0 second
Memory limit: 64 MB

The problem is so easy, that the authors were lazy to write a statement for it!

Input

The input stream contains a set of integer numbers Ai (0 ≤ Ai ≤ 1018). The numbers are separated by any number of spaces and line breaks. A size of the input stream does not exceed 256 KB.

Output

For each number Ai from the last one till the first one you should output its square root. Each square root should be printed in a separate line with at least four digits after decimal point.

Sample

input

output

1427  0

  876652098643267843

5276538

2297.0716

936297014.1164

0.0000

37.7757

代码:

using System;

using System.Globalization;

publicclassReverseRoot

{

privatestaticvoid Main()

   {

NumberFormatInfo nfi = NumberFormatInfo.InvariantInfo;

string[] input = Console.In.ReadToEnd().Split(

newchar[] { ' ', '\t', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);

for (int i = input.Length - 1; i >= 0; i--)

       {

double root = Math.Sqrt(double.Parse(input[i], nfi));

Console.WriteLine(string.Format(nfi, "{0:F4}", root));

       }

   }

}

总结:

1.学习了C#中的属性定义,并查找资料了解Console.In属性为什么还有方法ReadToEnd(),ReadToEnd()后面还有Split方法。

2.使用TextReader 类定义的输入方法ReadToEnd ( )和String.Split( )方法

3.了解NumberFormatInfo类及其成员

4.学习了输出格式

1.属性是一种类成员,它将字段和访问字段的方法组合在一起。属性不一定是值类型,它也可以是一个类的实例。所以说,属性是有类型的,这个类型有这个方法,就可以了!具体可参考http://bbs.csdn.net/topics/80284324和http://zhidao.baidu.com/question/320769258.html。ReadToEnd()方法返回的是string对象,Split()方法是String类的方法,故可在ReadToEnd()后面还有Split方法。个人总结,是先执行Console.In.ReadToEnd(),再将返回的String对象Split(),这也是input是数组的原因.

2.方法:string ReadToEnd() 是TextReader类定义的输入方法,功能是读取数据流中从当前位置到结尾的所有字符并将它们作为一个字符串返回。String.Split()返回包含此实例中的子字符串(由指定 Char 或 String 数组的元素分隔)的 String 数组,详细可搜MSDN。

3.NumberFormatInfo类,根据区域性定义设置数值格式以及如何显示数值,详细可搜MSDN。

4.学习了String.Format()方法格式化数据

创新互联www.cdcxhl.cn,专业提供香港、美国云服务器,动态BGP最优骨干路由自动选择,持续稳定高效的网络助力业务部署。公司持有工信部办法的idc、isp许可证, 机房独有T级流量清洗系统配攻击溯源,准确进行流量调度,确保服务器高可用性。佳节活动现已开启,新人活动云服务器买多久送多久。


分享名称:1001.ReverseRoot-创新互联
网站地址:http://cdkjz.cn/article/dhssos.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220