Héctor Tejeda Villela
Julio 2002
expar301.c.
expar302.for.
Solución
program factorial
integer n
write (*, *) 'Escribe el valor de n'
read (*, *) n
write (*, *) 'El factorial de ', n, ' es ' , int(fact(n))
stop
end
real function fact (n)
integer i, n
fact = 1
do i = 1, n
fact = fact*i
enddo
return
end
expar303.for.
program esc_matr
real x(100,100), e
integer m, n
write (*, *) "Introduce el valor del escalar"
read (*,*) e
write (*, *) "Introduce número de renglones y columnas"
read (*,*) m, n
if ( m>100 .OR. n>100 ) then
write (*,*) "¡Se excedio el tamaño de la matriz!"
stop
endif
call lee_mat(x, n, m, e)
call e_mat(x, n, m, e)
stop
end
subroutine lee_mat (x, r, c, e )
real x(100,*), e
integer r, c, i, j
do i = 1, r
do j = 1, c
write (*,* ) "(", i, ",", j, ")"
read (*,*) x(i,j)
enddo
enddo
end
subroutine e_mat (x, r, c, e )
real x(100,*), e
integer r, c, i, j
do i = 1, r
do j = 1, c
x(i,j) = x(i,j)*e
enddo
enddo
do i = 1, r
write (*, '(100(F8.2))') ( x(i,j), j=1,c)
enddo
end
Manda tu código usando esta liga.
NOTA: El examen es de caracter individual, códigos parecidos recibirán nota reprobatoria.