integer i,j
real x(20),y(20),z(20),sum,sqr
do 10 i=1,20
print 15,i,i
15 format(1x,'please input the values of x(',i2,') and y(',i2,')')
read*,x(i),y(i)
z(i)=x(i)*y(i)
sum=sum+z(i)
10 continue
print*,' i x(i) y(i) z(i)=x(i)*y(i)'
do 20 j=1,20
print 25,i,x(j),y(j),z(j)
25 format(1x,i2,3(4x,f5.3))
20 continue
sqr=sum**0.5
print*,'the square of the sum of all the z element is',sqr
end
![]()
Q3:
integer i,j
real a(20),max
do 10 i=1,20
print 15,i
15 format(1x,'please input the values of a(',i2,')')
read*,a(i)
if(max.ge.a(i)) goto 10
max=a(i)
10 continue
do 20 j=1,20
if(max.ne.a(j)) goto 20
goto 21
20 continue
21 print 25,j,max
25 format(1x,'the max number is at a(',i2,')=',f6.2)
end
![]()
Q4:
integer i,j
real w(8),sum1,sum2,ave,var,sta
do 10 i=1,8
print 15,i
15 format(1x,'please input the values of w(',i2,')')
read*,w(i)
sum1=sum1+w(i)
10 continue
ave=sum1/8
do 20 j=1,8
sum2=sum2+(w(j)-ave)**2
20 continue
var=sum2/8
sta=var**0.5
print*,'the average of this array w is',ave
print*,'the variance of this array w is',var
print*,'the stand deviation of this array w is',sta
end
![]()
Q5:
integer n,i
real up,down,w,sum,ans,x
print*,'this program is want to integral f(x)=sin(x)exp(x)'
print*,'please input the top and subscript'
read*,up,down
print*,'please input how many element you want to calculate'
read*,n
w=(up-down)/real(n)
do 10 i=1,n
x=(down-w/2+i*w)
sum=sum+sin(x)*exp(x)
10 continue
ans=w*sum
print*,'the answer is',ans
end
![]()
Q6:
integer b
real a,c
10 print*,'please input the values of a'
read*,a
if(a.ne.0) goto 20
print*,'a=0 please input again'
goto 10
20 call break(a,b,c)
print*,'the number of a is',a
print*,'the integral number of a is',b
print*,'the decimal fraction of a is',c
end
subroutine break(a,b,c)
integer b
real a,c
b=a
c=a-b
end
[Top]