回 帖 发 新 帖 刷新版面

主题:[讨论]菜鸟问题,但是急需高手们解答!

求高手帮助在原有基础上帮我改改,谢谢!!!                                                                                      module stu
  type student
  integer           :: num,hight,weigh 
  integer           :: chinese,math,english,ocean,total,aver
  integer           :: sum1,sum2
  real              :: aver1,aver2
  character(len=10) :: sex
  end type
end module 


subroutine infor(n)
use stu
implicit none
  integer i,j,k,m,n
  type(student)     :: s(n)
  type(student)     :: total,aver
  type(student)     :: temp
  type(student)     :: sex
  character(len=9)  :: sexs
  real,dimension(2) :: t=0,sum1=0,sum2=0,aver1=0,aver2=0,variance=0
  real,dimension(2) :: r
open(1,file='score.txt')
open(2,file='score1.txt')
open(3,file='score2.txt')
open(4,file='score3.txt')
 
write(2,'(10a9)') 'num', 'sex','hight','weigh','chinese','math','english','ocean','total','aver'
write(3,'(7a9)') 'num', 'chinese','math','english','ocean','total','aver'
write(4,'(10a9)') 'num', 'sex','hight','weigh','chinese','math','english','ocean','total','aver'

do i=1,20
read(1,*) s(i)%num,s(i)%sex,s(i)%hight,s(i)%weigh,s(i)%chinese,s(i)%math,s(i)%english,s(i)%ocean
s(i)%total=s(i)%chinese+s(i)%math+s(i)%english+s(i)%ocean
s(i)%aver=s(i)%total/4.0
write(2,'(i9,a9,8i9)') s(i)
sum1=sum1+s(i)%hight
sum2=sum2+s(i)%weigh
aver1=sum1/20
aver2=sum2/20
end do


 write(*,*)'please input the sex of the student you want to check:'
 read(*,*) sexs
 select case(sexs)

 case('female')
 do k=1,7
  do j=k+1,8
  if(s(k)%total<=s(j)%total)then
  temp=s(k)
  s(k)=s(j)
  s(j)=temp
  end if
  end do
end do
do m=1,8
write(3,'(9i9)') s(m)
end do
case default

end select

do i=1,20
t=t+(aver1-s(i)%hight)*(aver2-s(i)%weigh)
variance(1)=sqrt(variance(1)+(aver1(1)-s(i)%hight)**2)
variance(2)=sqrt(variance(2)+(aver2(2)-s(i)%weigh)**2)
end do
r=t/(variance(1)*variance(2))
write(4,"(8f9.2)") "r=",r

end subroutine 

program main
implicit none
integer :: n
call subroutine
end
--------------------Configuration: exam0001 - Win32 Debug--------------------
Linking...
exam0001.obj : error LNK2001: unresolved external symbol _SUBROUTINE@0
Debug/exam0001.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

exam0001.exe - 2 error(s), 0 warning(s)

回复列表 (共2个回复)

沙发

num      sex      hight    weigh    chinese  math     english  ocean
1        male     170      125      88       68       78       67
2        male     182      127      96       45       67       89
3        male     160      127      79       56       88       76
4        male     180      145      98       65       80       77
5        male     176      122      68       94       87       84
6        male     166      134      84       89       94       82 
7        male     176      130      97       78       88       68
8        male     173      146      93       68       96       85
9        male     174      155      66       78       94       85
10       male     171      98       66       47       86       54
11       male     168      97       85       65       70       95
12       male     178      100      87       56       96       56
13       female   165      105      70       80       76       86
14       female   157      98       77       68       67       80
15       female   159      100      90       67       88       57
16       female   167      96       85       85       76       47
17       female   164      121      86       67       79       86
18       female   167      105      98       57       98       76
19       female   164      102      95       57       93       75
20       female   168      100      66       78       67       79
这个是程序里的文件score.txt

板凳

call subroutine

改为

call infor

其他问题,自行解决。对你的学习有帮助

我来回复

您尚未登录,请登录后再回复。点此登录或注册