- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有一个 0.0-3.6 之间的数字数组,我想知道有多少个数字在这个区间内:0.0-0.2、0.2-0.4 等等,有人可以帮助我吗?多谢...我在 Fortran 中尝试过:
IMPLICIT NONE
INTEGER :: acoun, bcoun, ccoun, dcoun, ecoun, fcoun, gcoun, hcoun, icoun
INTEGER :: jcoun, kcoun, lcoun, mcoun, ncoun, ocoun, pcoun, qcoun, ia
INTEGER :: i1(4), i2(30), i3(30), i4(30), i5(30), i6(30), i7(30), i8(30), i9(30), i10(30), &
i11(30), i12(30), i13(30), i14(30), i15(30), i16(30), i17(30)
REAL :: a
OPEN(UNIT=10,FILE='DAN1',STATUS='OLD')
acoun=0.0
bcoun=0.0
ccoun=0.0
dcoun=0.0
ecoun=0.0
fcoun=0.0
gcoun=0.0
hcoun=0.0
icoun=0.0
jcoun=0.0
kcoun=0.0
lcoun=0.0
mcoun=0.0
ncoun=0.0
ocoun=0.0
pcoun=0.0
do i=1,119
READ(10,*)a
if (( a < 0.2d0 ).and.(a > 0.0d0) )then
i1(acoun)=i
acoun=acoun+1
elseif (( a < 0.4d0 ).and.(a > 0.2d0) )then
i2(bcoun)=i
bcoun=bcoun+1
elseif (( a < 0.6d0 ).and.(a > 0.4d0) )then
i3(ccoun)=i
ccoun=ccoun+1
elseif (( a < 0.8d0 ).and.(a > 0.6d0) )then
i4(dcoun)=i
dcoun=dcoun+1
elseif (( a < 1.0d0 ).and.(a > 0.8d0) )then
i5(ecoun)=i
ecoun=ecoun+1
elseif (( a < 1.2d0 ).and.(a > 1.0d0) )then
i6(fcoun)=i
fcoun=fcoun+1
elseif (( a < 1.4d0 ).and.(a > 1.2d0) )then
i7(gcoun)=i
gcoun=gcoun+1
elseif (( a < 1.6d0 ).and.(a > 1.4d0) )then
i8(hcoun)=i
hcoun=hcoun+1
elseif (( a < 1.8d0 ).and.(a > 1.6d0) )then
i9(icoun)=i
icoun=icoun+1 elseif (( a < 2.0d0 ).and.(a > 1.8d0) )then
i10(jcoun)=i
jcoun=jcoun+1
elseif (( a < 2.2d0 ).and.(a > 2.0d0) )then
i11(kcoun)=i
kcoun=kcoun+1
elseif (( a < 2.4d0 ).and.(a > 2.2d0) )then
i12(lcoun)=i
lcoun=lcoun+1
elseif (( a < 2.6d0 ).and.(a > 2.4d0) )then
i13(mcoun)=i
mcoun=mcoun+1
elseif (( a < 2.8d0 ).and.(a > 2.6d0) )then
i14(ncoun)=i
ncoun=ncoun+1
elseif (( a < 3.0d0 ).and.(a > 2.8d0) )then
i15(ocoun)=i
ocoun=ocoun+1
elseif (( a < 3.2d0 ).and.(a > 3.0d0) )then
i16(pcoun)=i
pcoun=pcoun+1
elseif (a > 3.2d0)then
i17(qcoun)=i
qcoun=qcoun+1
endif
enddo
WRITE(*,*) i1(acoun),acoun
WRITE(*,*) i2(bcoun),bcoun
WRITE(*,*) i3(ccoun),ccoun
WRITE(*,*) i4(dcoun),dcoun
WRITE(*,*) i5(ecoun),ecoun
WRITE(*,*) i6(fcoun),fcoun
WRITE(*,*) i7(gcoun),gcoun
WRITE(*,*) i8(hcoun),hcoun
WRITE(*,*) i9(icoun),icoun
WRITE(*,*) i10(jcoun),jcoun
WRITE(*,*) i11(kcoun),kcoun
WRITE(*,*) i12(lcoun),lcoun
WRITE(*,*) i13(mcoun),mcoun
WRITE(*,*) i14(ncoun),ncoun
WRITE(*,*) i15(ocoun),ocoun
WRITE(*,*) i16(pcoun),pcoun
WRITE(*,*) i17(qcoun),qcoun
close(10)
ENDPROGRAM sorting"
此文件给出了一些值,但它们不正确,该程序在每个间隔中都进行了计数。
我在 bash 中尝试过这个
我尝试在 bash 中使用 if 语句,例如:
if [$var > 0.0 -a 0.2 < $var]then
echo "$var" >> file
wc -l file
但它也不起作用
非常感谢您的帮助......
最佳答案
Bash 不支持浮点运算,但 awk 支持:
假设文件
包含所有数字,在单独的行中,此脚本应该执行您想要的操作:
$ awk '{a[int($1/0.2)]++}END{for(i in a)print i*0.2 "-" (i+1)*0.2, a[i]}' file | sort -n
关于linux - 按间隔对数字进行分组 : I have an array of numbers between 0. 0-3.6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20886904/
从 angular 5.1 更新到 6.1 后,我开始从我的代码中收到一些错误,如下所示: Error: ngc compilation failed: components/forms/utils.
我正在学习 Typescript 并尝试了解类型和接口(interface)的最佳实践。我正在玩一个使用 GPS 坐标的示例,想知道一种方法是否比另一种更好。 let gps1 : number[];
type padding = [number, number, number, number] interface IPaddingProps { defaultValue?: padding
这两种格式在内存中保存结果的顺序上有什么区别吗? number = number + 10; number += 10; 我记得一种格式会立即保存结果,因此下一行代码可以使用新值,而对于另一种格式,
在 Python 匹配模式中,如何匹配像 1 这样的文字数字在按数字反向引用后 \1 ? 我尝试了 \g用于此目的的替换模式中可用的语法,但它在我的匹配模式中不起作用。 我有一个更大的问题,我想使用一
我的源文件here包含 HTML 代码,我想将电话号码更改为可在我的应用程序中单击。我正在寻找一个正则表达式来转换字符串 >numbernumber(\d+)$1numbernumber<",我们在S
我们有一个包含 2 个字段和一个按钮的表单。我们想要点击按钮来输出位于 int A 和 int B 之间的随机整数(比如 3、5 或 33)? (不需要使用 jQuery 或类似的东西) 最佳答案 你
我收到以下类型错误(TypeScript - 3.7.5)。 error TS2345: Argument of type '(priority1: number, priority2: number
只想创建简单的填充器以在其他功能中使用它: function fillLine(row, column, length, bgcolor) { var sheet = SpreadsheetApp
我有一个问题。当我保存程序输出的 *.txt 时,我得到以下信息:0.021111111111111112a118d0 以及更多的东西。 问题是: 这个数字中的“d0”和“a”是什么意思? 我不知道“
首先:抱歉标题太长了,但我发现很难用一句话来解释这个问题;)。是的,我也四处搜索(这里和谷歌),但找不到合适的答案。 所以,问题是这样的: 数字 1-15 将像这样放在金字塔中(由数组表示):
我想从字符串中提取血压。数据可能如下所示: text <- c("at 10.00 seated 132/69", "99/49", "176/109", "10.12 I 128/51, II 1
当尝试执行一个简单的 bash 脚本以将前面带有 0 的数字递增 1 时,原始数字被错误地解释。 #!/bin/bash number=0026 echo $number echo $((number
我有一个类型为 [number, number] 的字段,TypeScript 编译器(strict 设置为 true)出现问题,提示初始值值(value)。我尝试了以下方法: public shee
你能帮我表达数组吗:["232","2323","233"] 我试试这个:/^\[("\d{1,7}")|(,"\d{1,7}")\]$/ 但是这个表达式不能正常工作。 我使用 ruby(rail
这个问题在这里已经有了答案: meaning of (number) & (-number) (4 个回答) 关闭6年前. 例如: int get(int i) { int res = 0;
我正在考虑使用 Berkeley DB作为高度并发的移动应用程序后端的一部分。对于我的应用程序,使用 Queue对于他们的记录级别锁定将是理想的。但是,如标题中所述,我需要查询和更新概念建模的数据,如
我正在尝试解决涉及重复数字的特定 JavaScript 练习,为此我需要将重复数字处理到大量小数位。 目前我正在使用: function divide(numerator, denominator){
我有这个数组类型: interface Details { Name: string; URL: string; Year: number; } interface AppState {
我们正在使用 Spring 3.x.x 和 Quartz 2.x.x 实现 Web 应用程序。 Web 服务器是 Tomcat 7.x.x。我们有 3 台服务器。 Quartz 是集群式的,因此所有这
我是一名优秀的程序员,十分优秀!