Read 15 elements in a matrix A type vector. Create matrix B be the factorial of the corresponding element of matrix A

Asked

Viewed 118 times

1

Read 15 elements in a matrix A vector type. Create a matrix B of the same dimension, where Each element of the matrix B is the factorial of the corresponding element of the matrix A. Display the elements of the matrix B ordered crescently.

Good Afternoon, someone could help me. I am in doubt of how I can make the program to display in ascending order. Thank you from now!!

enter the code here

 //Ex 3 Fatorial
 #include <stdio.h>

int main (){

int fat[12],i,vet[12];

for (i=0; i<12; i++)
{
printf("Digite um numero:\n");
scanf ("%d",&vet[i]);
}

for (i = 0; i < 12; i++) {
    for (fat[i] = 1; vet[i] > 1; vet[i]--) {
        fat[i] *= vet[i];
    }
    {
        printf ("\n\n");
    }
    printf("%d", fat[i]);
}   

return 0;
}
  • 1

    Sort the array in ascending order. There are many sorting methods, see: https://pt.wikipedia.org/wiki/Algoritmo_de_sort%C3%A7%C3%A3o

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.