База ответов ИНТУИТ

Программирование больших вычислительных задач на современном Фортране с использованием компиляторов Intel

<<- Назад к вопросам

Для типа point выберите правильный код финальной процедуры DeletePoint
module flowinteger, private :: INDEX  type point    integer x,y,z    integer color    logical stat        contains      final :: DeletePoint      end type point  CONTAINS  ...    subroutine InitFlow()      INDEX=0    end subroutine InitFlowend module flow  

(Отметьте один правильный вариант ответа.)

Варианты ответа
    subroutine DeletePoint()      class(point) pt      write(*,*) pt      write(*,*) "Point is deleted...."      INDEX=INDEX+1    end subroutine     
    subroutine DeletePoint(pt)      class(point) pt      write(*,*) pt      write(*,*) "Point is deleted...."      INDEX=INDEX+1    end subroutine    
    subroutine DeletePoint(pt)      type(point) pt      write(*,*) pt      write(*,*) "Point is deleted...."      INDEX=INDEX+1    end subroutine        
(Верный ответ)
    subroutine DeletePoint()      type(point) pt      write(*,*) pt      write(*,*) "Point is deleted...."      INDEX=INDEX+1    end subroutine  
    subroutine DeletePoint()      write(*,*) pt      write(*,*) "Point is deleted...."      INDEX=INDEX+1    end subroutine
Похожие вопросы
В головной программе используется модуль flow. Объявлена переменная PT типа point. Какие из процедур в типе point могут изменить приватную часть переменной PT ?
module flow  type point    integer x    integer y    real, private :: cp  contains    procedure, nopass :: proc1    procedure proc2    procedure, pass :: proc3    procedure, nopass :: proc4    procedure proc5    procedure show  end type point  contains    subroutine proc1(pt,val)      type(point) pt      real val      pt.cp = val    end subroutine proc1    subroutine proc2(pt)      class(point) pt      pt.cp=real(pt.x+pt.y)    end subroutine proc2    subroutine proc3(pt)      class(point) pt      integer tmp      tmp=pt.x; pt.x=pt.y; pt.y=tmp    end subroutine proc3    subroutine proc4(pt)      type(point) pt      if (pt.cp<=0) write(*,*) "ERROR"    end subroutine proc4    subroutine proc5(pt,M,N,S)      class(point) pt      integer M,N      real, optional :: S      pt.x=pt.x+N      pt.y=pt.y+M      if (present(S)) call random_number(pt.cp)    end subroutine proc5end module flow        
Модуль
module mod_1  type plot    integer x1,y1,x2,y2    integer, private :: color(255)  end type plot  type indicator    type (plot) plt    logical :: free    character(4), public :: date  end type indicator  type card    type (indicator) indic    integer fparam    integer, private :: sparam  end type cardend module mod_1        

используется в головной программе.

Объявлена переменная

type(card) cdУкажите верные варианты доступа к полям производного типа.
Модуль
module mod_1  type plot    integer x1,y1,x2,y2    integer color(255)  end type plot  type indicator    type (plot) plt    logical, private :: free    character(4) date  end type indicator  type card    type (indicator) indic    integer fparam    integer sparam  end type cardend module mod_1        

используется в головной программе.

Объявлена переменная

type(card) cdУкажите верные варианты доступа к полям производного типа.
Дан модуль, который используется в головной программе
module mod_1  type maps    integer x,y    integer color    logical, private :: status  end type maps  type, extends (maps) :: e_maps    integer segment    character, private :: code  end type e_mapsend module mod_1        

В головной программе объявлена переменная

type (e_maps) EMУкажите верные варианты доступа к полям производного типа из головной программы.
В программе объявлены типы и переменная
  type point    complex x,y  end type point  type NewType    integer a    type (point) z(3)    character(4) border(2)  end type NewType    type (NewType) pt(10)        
Укажите верные варианты инициализации элемента pt(5)
Даны два типа описанных в модуле hydro
module hydro  type point    real(8) x    real(8) y  end type point  type, extends (point) :: expoint    real(16), allocatable :: x1,y1,x2,y2    character(8) code  end type expoint...end module hydro
В тип expoint добавляются две модульные процедуры procA и procB. Процедуры не имеют формальных параметров. На сколько изменится размер в байтах переменной типа expoint после добавления процедур ?
Описан модуль, который подключен к головной программе
module mod_1 integer, private :: A=1,B=1,C=1 integer, protected :: D, E private SetA public  F, init contains   subroutine SetA(X)     integer X     A=X+1   end subroutine SetA   subroutine init_D_E(x,y)     integer x,y     D=X*10; E=Y*2   end subroutine init_D_E   integer function F     F=A+D+E   end function Fend module mod_1        
Какой результат вернет функция F после вызова процедуры init_D_E(2,3) в головной программе ?
Описан модуль, который подключен к головной программе
module mod_1 integer, protected :: A=1,B=1,C=1 integer, private :: D, E private SetA public  F, init contains   subroutine SetA(X)     integer X     A=X-1   end subroutine SetA   subroutine init_D_E(x,y)     integer x,y     D=X*10; E=Y*2; call SetA(0)   end subroutine init_D_E   integer function F     F=A+D+E   end function Fend module mod_1        
Какой результат вернет функция F после вызова процедуры init_D_E(4,5) в головной программе ?
Какое значение будет находиться в поле a переменной ex1 после вызова call ex1.solve() в следующей программе ?
module mod_1  abstract interface    integer function func(x)      integer x    end function func  end interface      type region    integer, private :: a    integer, private :: b    procedure (func), pointer, nopass :: funct        contains      procedure solve  end type regioncontains  subroutine solve(rg)    class(region) rg    rg.a=rg.funct(rg.a)  end subroutine solveend module mod_1program proguse mod_1type (region) ex1ex1.a=2; ex1.b=3; ex1.funct=>Fcall ex1.solve()containsinteger function F(x)  integer x  F=x*x+xend function FEND
Какое значение будет присвоено переменной k в результате выполнения оператора select type в следующем фрагменте программы ?
type point  integer x, yend type pointtype, extends(point) :: point_ex  integer z  integer color  logical errorend type point_extype, extends(point_ex) :: point_phys  real vx  real vy  real vz  real tmend type point_phystype, extends(point_phys) :: point_mech  character(32) name  character(8)  codeend type point_mechinteger kclass (*), pointer :: ptrtype  (point_ex), target :: pt_exclass (point_phys), allocatable, target :: pt_phclass (point_mech), allocatable, target :: pt_mhallocate(pt_ph,source=point_phys(1,2,3,4,.true.,0.0,0.0,0.0,0.0))allocate(pt_mh,source=point_mech(5,6,7,8,.true.,0.0,0.0,0.0,0.0,"A","B"))ptr=>pt_ph  select type (ptr)    type is (point_ex);    k=ptr.x    class is (point);      k=ptr.y    class is (point_mech); k=ptr.color    class default;         k=0  end select ...