当前位置:网站首页>FORTRAN 77 reads some data from the file and uses the heron iteration formula to solve the problem
FORTRAN 77 reads some data from the file and uses the heron iteration formula to solve the problem
2020-11-08 01:33:00 【wangxuwei】
Required :
1. There is no limit to the number of data , Automatically count and print serial numbers
2. When you encounter a negative number , Skip the recipe , Print directly and mark
3. encounter 0.0, The program to stop
Heron Iterative method .
- initialization (X0 = A);(x1 =1/2*{x0+A/ x0});
- Calculation (Delta_k = |x1 - x0|;
- if (Delta_k < epsilon), return (x), The algorithm ends ;
- (x1 =1/2*{x0+A/ x0});
- Back to page 2 Step ;
C
C heronus1.f
C
C Unlimited number of data, automatic counting and printing serial number
C When negative numbers are encountered,skip square root, print them directly and mark them
C Encountered 0.0, the program stopped
PROGRAM heronus1
EPS=.1 E-4
I=0
OPEN(11,file='fheronus.dat')
10 READ(11,*)A
I=I+1
IF (A) 1,2,30
1 WRITE(6,100) I,A
100 FORMAT(1X, I6,10X,F10.6,' NEGATIVE NUMBER')
GO TO 10
2 STOP 'END OF JOB'
30 X0=A
20 X1=.5*(X0+A/X0)
IF (ABS(X1-X0).LT.EPS) GO TO 40
X0=X1
GO TO 20
40 WRITE(6,110) I,A,X1
110 FORMAT(1X, I6,2F10.6)
3 CONTINUE
GO TO 10
END
Data should be divided into rows , Not spaces , And use 0.0 end :
$ cat fheronus.dat
1
2
3
4
5
6
7
8
9
10
11
12
12
13
13
14
16
21
22
13
25
22
13
21
52
32
-23
121
12
0.0
function :
$ f77 heronus1.f
$ a.out
1 1.000000 1.000000
2 2.000000 1.414214
3 3.000000 1.732051
4 4.000000 2.000000
5 5.000000 2.236068
6 6.000000 2.449490
7 7.000000 2.645751
8 8.000000 2.828427
9 9.000000 3.000000
10 10.000000 3.162278
11 11.000000 3.316625
12 12.000000 3.464102
13 12.000000 3.464102
14 13.000000 3.605551
15 13.000000 3.605551
16 14.000000 3.741657
17 16.000000 4.000000
18 21.000000 4.582576
19 22.000000 4.690416
20 13.000000 3.605551
21 25.000000 5.000000
22 22.000000 4.690416
23 13.000000 3.605551
24 21.000000 4.582576
25 52.000000 7.211102
26 32.000000 5.656854
27 -23.000000 NEGATIVE NUMBER
28121.000000 11.000000
29 12.000000 3.464102
STOP END OF JOB
ubutnu18.04 Next gfortran-10 Compile and pass (vax780 Of f77 Also tested )
版权声明
本文为[wangxuwei]所创,转载请带上原文链接,感谢
边栏推荐
- 2020-11-07:已知一个正整数数组,两个数相加等于N并且一定存在,如何找到两个数相乘最小的两个数?
- 状态压缩:对动态规划进行降维打击
- Web Security (3) -- CSRF attack
- ubuntu实时显示cpu、内存占用率
- 在Ubuntu上体验最新版本EROFS
- iOS上传App Store报错:this action cannot be completed -22421 解决方案
- 获取树形菜单列表
- 14000 word distributed transaction principle analysis, master all of them, are you afraid of being asked in the interview?
- Littlest jupyterhub| 02 using nbgitpuller to distribute shared files
- 虚拟DOM中给同一层级的元素设置固定且唯一的key为什么能提高性能
猜你喜欢

Improvement of maintenance mode of laravel8 update

Judging whether paths intersect or not by leetcode

The software in your host has terminated an established connection. resolvent

The emergence and significance of micro service

November 07, 2020: given an array of positive integers, the sum of two numbers equals N and must exist. How to find the two numbers with the smallest multiplication?

c# 表达式树(一)

Data structure and sorting algorithm

获取树形菜单列表

The road of cloud computing: a free AWS cloud server

Privacy violation and null dereference of fortify vulnerability
随机推荐
爆一个VS2015 Update1更新带来的编译BUG【已有解决方案】
Blazor 准备好为企业服务了吗?
The most detailed usage guide for perconaxtradbcluster8.0
More than 50 object detection datasets from different industries
VC6 compatibility and open file crash resolution
Idea - the. IML file was not automatically generated by the project
14000 word distributed transaction principle analysis, master all of them, are you afraid of being asked in the interview?
面部识别:攻击类型和反欺骗技术
Cpp(二) 创建Cpp工程
Basic knowledge of C + +
到底选openstack还是vmware?
Learn Scala if Else statement
Ubuntu下搜狗输入法的下载安装及配置
Python image recognition OCR
获取树形菜单列表
On the stock trading of leetcode
WPF personal summary on drawing
在Ubuntu上体验最新版本EROFS
麦格理银行借助DataStax Enterprise (DSE) 驱动数字化转型
Data transmission of asynchronous serial communication controlled by group bus communication