![](/user_photo/91653_YtWm7.jpg)
Добавил:
Chupapi_Munyanya
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:
program variant
integer, parameter :: N = 100
real :: matrix(N,N)
real :: C(N)
real :: P(N)
real :: X(N)
real :: maximum
LOGICAL :: flag
flag = .TRUE.
read (*,*) NMAX
read (*,*) (C(i),i=1,NMAX)
read (*,*) (P(i),i=1,NMAX)
call compare(C, P, flag, NMAX)
if(flag) THEN
do i=1,NMAX
call find_max(C(i), P(i), maximum)
X(i) = maximum
end do
end if
WRITE (*,*) (X(i),i=1,NMAX)
end program
subroutine compare (C, P, flag, NMAX)
real :: C(NMAX), P(NMAX)
integer :: NMAX
LOGICAL :: flag
integer :: i
i = 1
flag = .true.
do while(i<NMAX .and. flag)
do j=1, NMAX
if(P(I)==C(j)) THEN
flag = .false.
exit
end if
end do
i=i+1
end do
end subroutine
subroutine find_max(A, B, maximum)
real :: A, B, maximum
integer :: NMAX
if (A > B) THEN
maximum = A
ELSE
maximum = B
end if
end subroutine
integer, parameter :: N = 100
real :: matrix(N,N)
real :: C(N)
real :: P(N)
real :: X(N)
real :: maximum
LOGICAL :: flag
flag = .TRUE.
read (*,*) NMAX
read (*,*) (C(i),i=1,NMAX)
read (*,*) (P(i),i=1,NMAX)
call compare(C, P, flag, NMAX)
if(flag) THEN
do i=1,NMAX
call find_max(C(i), P(i), maximum)
X(i) = maximum
end do
end if
WRITE (*,*) (X(i),i=1,NMAX)
end program
subroutine compare (C, P, flag, NMAX)
real :: C(NMAX), P(NMAX)
integer :: NMAX
LOGICAL :: flag
integer :: i
i = 1
flag = .true.
do while(i<NMAX .and. flag)
do j=1, NMAX
if(P(I)==C(j)) THEN
flag = .false.
exit
end if
end do
i=i+1
end do
end subroutine
subroutine find_max(A, B, maximum)
real :: A, B, maximum
integer :: NMAX
if (A > B) THEN
maximum = A
ELSE
maximum = B
end if
end subroutine
Соседние файлы в папке Коды 5.2