Ir para conteúdo
Fórum Script Brasil

felipeziggg

Membros
  • Total de itens

    1
  • Registro em

  • Última visita

Sobre felipeziggg

felipeziggg's Achievements

0

Reputação

  1. /*Gostaria de saber se alguém pode me ajudar a fazer o limite superior(ls) Exemplo: 0 1 2 3 4 5 6 7 8 9 10 ls = 9 li = 1 */ #include <stdio.h> #include <stdlib.h> // global int soma; void showImpares1(short n) { if (n==0) return; printf("%d ", 2*n - 1); showImpares1(n-1); } void showImpares2(short n) { if (n==0) return; showImpares2(n-1); printf("%d ", 2*n - 1); } int somaImpares(short n) { if (n==0) return 0; return 2*n -1 + somaImpares(n-1); } void showLimitSup(short n, short ls){ if(n==ls) return; printf("%d ", 2*n - 1); showLimitSup(n-1, ls); } void showLimitInf(short n, short li){ if(n==li) return; printf("%d ", 2*n - 1); showLimitInf(n-1, li); } int main(int argc, char *argv[]){ printf("Entre com um natural pequeno: "); int n; int li; int ls; scanf("%d", &n); showImpares1(n); printf("\n"); showImpares2(n); printf("\n"); printf("soma = %d\n",somaImpares(n));printf("\n"); printf("Limite Superior: \n"); showLimitSup(n, ls); printf("\n");printf("\n"); printf("Limite Inferior: \n"); showLimitInf(n, li); printf("\n"); system("PAUSE"); return 0; }
×
×
  • Criar Novo...