简体   繁体   English

如何使用 Javascript 解决此问题

[英]How to solve this problem using Javascript

In weather.dat there are data with meteorological surveys.在weather.dat 中有气象调查的数据。 The first column contains the day of the month, while the second and the third contain respectively the temperature maximum and minimum for that day.第一列包含月份中的某一天,而第二列和第三列分别包含当天的最高温度和最低温度。 Write a program that, given the input file, returns the day with the smallest temperature range.编写一个程序,给定输入文件,返回温度范围最小的日期。

this is the link of a the data displayed in Atom:这是 Atom 中显示的数据的链接:

The file that contains these data has a.dat extension, I have never used it so far so I don't even know how should I retrieve these data in my script?包含这些数据的文件具有 .dat 扩展名,到目前为止我从未使用过它,所以我什至不知道应该如何在我的脚本中检索这些数据? (should I rewrite them directly in the arrays?) (我应该直接在数组中重写它们吗?)

Please help!请帮忙!

In general files are separated into txt and binary files so extracting data is general for these two file types.一般来说,文件分为 txt 和二进制文件,因此提取数据对于这两种文件类型是通用的。 File extensions are often used just for clarification.文件扩展名通常仅用于说明。

How to extract data from a txt(.dat) file 如何从 txt(.dat) 文件中提取数据
Javascript file reader Javascript文件阅读器

As well idea for the given task:以及给定任务的想法:

  • Save days into a collection (optional)将天数保存到集合中(可选)
  • Iterate over the collection of days遍历天的集合
  • Calculate the temperature range for each day (Max - Min)计算每天的温度范围(最大值 - 最小值)
  • Find the min value找到最小值

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM