Carlos Henrique Posted February 22, 2016 at 07:35 PM Report Share #593744 Posted February 22, 2016 at 07:35 PM (edited) Usando Pascal, como montar um programa recursivo que mostre em vídeo a seguinte sequencia? 5 10 15 20 25 6 12 18 24 7 14 21 8 16 9 Não estou conseguindo montar a fórmula para achar os valores das linhas e colunas. Nesse caso vamos supor N = 5. Edited February 23, 2016 at 09:04 AM by pwseo tags code, cleanup Link to comment Share on other sites More sharing options...
Carlos Henrique Posted February 22, 2016 at 08:07 PM Author Report Share #593745 Posted February 22, 2016 at 08:07 PM (edited) Sou iniciante: usando procedimentos a seguir: Procedure imprime_coluna( i{e}, N{e}: integer ); begin if i <= N then begin write((i)*(n):4); imprime_coluna(i + 1, n); end; end; Procedure Imprime_linha( i{e},N{e}: integer ); begin if i - 1 <= N then begin imprime_coluna(i, N); writeln; writeln; imprime_linha( i+1, N ); end; que fornece um resultado parecido, mas não verdadeiro. Não consigo chegar a uma fórmula que resolva tal problema. Edited February 23, 2016 at 09:08 AM by pwseo syntax highlight, cleanup Link to comment Share on other sites More sharing options...
pwseo Posted February 23, 2016 at 09:14 AM Report Share #593749 Posted February 23, 2016 at 09:14 AM Carlos Henrique, Qual será o output quando N = 1? Com apenas aquele exemplo que deste, não fica claro como deve ser estruturado o procedimento. Outro ponto importante: Qual o output que obténs com o código que fizeste? Será interessante vermos onde difere do esperado. Link to comment Share on other sites More sharing options...
Carlos Henrique Posted February 23, 2016 at 10:09 AM Author Report Share #593754 Posted February 23, 2016 at 10:09 AM quando N= 1 , obtem-se 1. com N = 5 , obtemos o seguinte output: 5 10 15 20 25 10 15 20 25 15 20 25 20 25 25 Link to comment Share on other sites More sharing options...
pwseo Posted February 23, 2016 at 10:22 AM Report Share #593755 Posted February 23, 2016 at 10:22 AM Então é suposto obter os seguintes resultados? N = 1 1 N = 2 2 4 3 N = 3 3 6 9 4 8 5 É importante termos exemplos do funcionamento esperado, caso contrário torna-se fácil escrever código que replique apenas o teu exemplo inicial mas que falha nos restantes. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now