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

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

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

В программе объявлены типы и переменная
  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)

(Ответ считается верным, если отмечены все правильные варианты ответов.)

Варианты ответа
pt(5)=NewType(50,[point((1.0,1.0),(2.0,2.0)), &                  point((0.0,1.0),(3.0,8.0)), &                  point((0.0,0.0),(3.0,0.0))],['A101','B120'])        
(Верный ответ)
pt(5)=NewType(50,0.0,['A101','B120'])
pt(5)=NewType(50,point(0.0,0.0),['A101','B120'])(Верный ответ)
pt(5)=NewType(50,point(0.0),['A101','B120'])
pt(5)=NewType(50,[(1.0,1.0),(2.0,2.0)],'A101')
Похожие вопросы
Модуль
module mod_1  type region    integer x(4)    real R  end type region  type blk    logical st(3)    character(5), public :: name(2)  end type blk  type NewType    type (region) reg(20)    type (blk)    bee(30)  end type NewTypeend module mod_1        

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

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

type(NewType) NTУкажите верные варианты доступа к полям производного типа.
Модуль
module mod_1  type region    integer x1,y1,x2,y2  end type region  type blk    logical st(3)    character(5), private :: name  end type blk  type NewType    type (region) reg    type (blk)    bee  end type NewTypeend module mod_1        

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

Описан массив

type (NewType) matrix(10,10,100)Укажите верные варианты инициализации элемента matrix(1:5:2,:,20)
Модуль
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 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Укажите верные варианты доступа к полям производного типа.
Объявлены следующие типы и переменные.
  type sma    real p(100)    real mid(100)    logical res  end type sma  type, extends (sma) :: ssma    real middle  end type ssma  type uma    type (sma) sm(100)    complex p(100)    logical ret    character bis  end type uma  class (sma), pointer :: polym  type (uma),  target  :: um1  type (ssma), target  :: ssm1        
Какие справедливы прикрепления ссылки polym?
В головной программе используется модуль 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        
Какое значение будет присвоено переменной 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 ...
Дан модуль, который используется в головной программе
module mod_1  type rectangle    integer x1,y1,x2,y2    integer color    character, private :: name  end type rectangle  type, extends (rectangle) :: roundrect    integer radius    real, public :: center  end type roundrectend module mod_1        

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

type (rectangle) rctУкажите верные варианты доступа к полям производного типа из головной программы.
Дан модуль, который используется в головной программе
module mod_1  type person    integer year    character(64), private ::  name="ABC"    character(64), private :: sname="DEF"  end type person  type, extends (person) :: student    logical, private :: status    character, public :: group  end type studentend module mod_1        

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

type (person) pstype (student) st
Укажите верные варианты доступа к полям производного типа из головной программы.
Какое значение будет присвоено переменной k в результате выполнения оператора select type в следующем фрагменте программы ?
type point  integer x, yend type pointtype, extends(point) :: point_ex  integer zend type point_extype, extends(point_ex) :: point_phys  real vx  real tmend type point_phystype, extends(point_phys) :: point_mech  character(32) nameend type point_mechclass (point_ex), pointer :: polyclass (point), target, allocatable :: ptclass (point_ex), target, allocatable  :: pt_exclass (point_phys), target, allocatable  :: pt_phclass (point_mech), target, allocatable  :: pt_mhinteger kallocate (pt, source=point(1,2))allocate (pt_ex, source=point_ex(3,4,5))allocate (pt_ph, source=point_phys(6,7,8,0.0,9.0))allocate (pt_mh, source=point_mech(9,10,11,0.0,0.0,"ABC"))poly=>pt_mh  select type (poly)    class is (point_ex);   k=poly.x    class is (point_phys); k=poly.z    class default;         k=0  end select ...