ayuda con ejercicios básicos lenguaje C
Publicado por Alfonzo (11 intervenciones) el 25/02/2020 03:29:04
hola buenas, podrían ayudarme con estos ejercicios basicos de programacion de lenguaje C?


Valora esta pregunta


0
#include <stdio.h>
#include <time.h> /* time */
#include <stdlib.h> /* srand y rand */
#define SZ 100
int random();
void ordenar(int v[]);
int main()
{
int numeros[SZ];
int a, b, c, i;
a = b = c = 0;
srand(time(NULL));
for(i = 0; i < SZ; i++)
numeros[i] = random();
ordenar(numeros);
printf("\nLos numeros son:\n");
for(i = 0; i < SZ; i++)
{
if (numeros[i] >= 25 && numeros[i] <= 35) a++;
else if (numeros[i] < 12) b++;
else if (numeros[i] > 30) c++;
printf( "%4d", numeros[i]);
}
printf("\n");
printf("\nnumeros menores de 12: %d", b);
printf("\nNumeros mayores de 30: %d", c);
printf("\nNumeros entre 25 y 35: %d", a);
printf("\n");
return 0;
}
int random()
{
return rand() % 100 + 1;
}
void ordenar(int v[])
{
int valor;
int j;
for(int i = 1; i < SZ; i++) {
valor = v[i];
j = i;
while( j > 0 && valor < v[j-1] ) {
v[j] = v[j-1];
j--;
}
v[j] = valor;
}
}
#include <stdio.h>
int main()
{
int i, suma = 0;
for(i = 1; i <= 15; i++)
suma += i;
printf("\nLa suma es: %d\n", suma);
return 0;
}