SOLUCIÓN:
program suma_cifras integer :: n, m, suma print *, "Introduza un número: " read *, n m = n; suma = 0 do suma = suma + mod(m, 10) m = m/10 if(m == 0) exit end do print *, "A suma das cifras de ", n, " é ", suma stop end program suma_cifras
SOLUCIÓN:
subroutine suprime_fila_col(a, nf, nc, f, c, b) integer, dimension(nf, nc), intent(in) :: a integer, intent(in) :: nf, nc, f, c integer, dimension(:,:), allocatable, intent(out) :: b do i = 1, nf if(i == f) cycle do j = 1, nc if(j == c) cycle b(k, l) = a(i, j) l = l + 1 end do k = k + 1; l = 1 end do return end subroutine suprime_fila_col
-1.231 2.453 ... ...
SOLUCIÓN:
subroutine le_datos(x, y, n) real, dimension(100), intent(out) :: x, y integer, intent(out) :: n open(1, file = "datos.dat") n = 0 do read (1, 2) x(n + 1), y(n + 1) 2 format(f6.3, t10, f6.3) n = n + 1 end do 1 close(1) return end subroutine le_datos
zk = xiyi-k k = 1,..., n | (1) |
Usar yi-k = 1 para os valores i k.
SOLUCIÓN:
program convolucion real, dimension(100) :: x, y, z integer :: n call le_datos(x, y, n) do k = 1, n z(k) = 0 if(i <= k) then z(k) = z(k) + x(i) else z(k) = z(k) + x(i)*y(i - k) end if end do stop end program convolucion