
Llenar un arreglo de 15 elementos con números múltiplos de 3 y que se generen de forma aleatoria.
Publicado por carlos (1 intervención) el 09/12/2022 21:23:23
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<time.h>
int arr[15][15],x,y,acu;
main()
{
srand(time(NULL));
for(x=0;x<15;x++)
for(y=0;y<14;y++)
arr[x][y]=3+rand()%30;
for(x=0;x<15;x++)
{
acu=0;
for(y=0;y<15;y++)
acu=acu+arr[x][y];
arr[x][14]=acu;
}
for(x=0;x<15;x++)
{
printf("\n");
for(y=0;y<15;y++)
printf(" %d ",arr[x][y]);
}
getch();
}
llevo eso pero me falta que los genere en múltiplos de 3
#include<conio.h>
#include<stdlib.h>
#include<time.h>
int arr[15][15],x,y,acu;
main()
{
srand(time(NULL));
for(x=0;x<15;x++)
for(y=0;y<14;y++)
arr[x][y]=3+rand()%30;
for(x=0;x<15;x++)
{
acu=0;
for(y=0;y<15;y++)
acu=acu+arr[x][y];
arr[x][14]=acu;
}
for(x=0;x<15;x++)
{
printf("\n");
for(y=0;y<15;y++)
printf(" %d ",arr[x][y]);
}
getch();
}
llevo eso pero me falta que los genere en múltiplos de 3
Valora esta pregunta


0