- 积分
- 677
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2013-5-21
- 最后登录
- 1970-1-1
|

楼主 |
发表于 2016-4-26 15:35:09
|
显示全部楼层
!逐行读取站号,当读到下一个站时,站号前一个站肯定不相等,这时让计数变量+1
!变量声明
integer sta_id(0:1000) ,temp,count !sta_id的数组大小只要比你收录的站数多就行,不行就2000,再不行10000
!temp是来暂时存储站号的
!count为计数用
!从上至下,依次读取各个行的站号
integer,parameter::n=56940
sta_id=0
count=0
open(30,file="F:\work\gongbao\2015\1\1.txt")
do i=1,n
read(30,*)temp
!print*,temp
end do
close(30)
open(50,file="F:\work\gongbao\2015\1\out1.txt")
do i=1,n !这里的10000看你的文件行数有多少了
!read(1,*) temp
if(temp/=sta_id(count)) then
count=count+1
sta_id(count)=temp
write(50,*)sta_id(count)
else
end if
end do
print*,'zongzhanzhu:',count
close(50)
end
试了一下,还是count只有一个站。而且是最后一个站,不知道您方便不,原始txt已经上传到网上,不知道下载需要金钱不,或者您有联系邮箱方便传你吗,真是太麻烦了。 |
|