public class Fiesta
{
private int[] _edades;
private char[] _sexos;
private int _cantHombres;
private int _cantMujeres;
private double _promedioEdadHombres;
private double _promedioEdadMujeres;
private int _edadMasJoven;
public Fiesta()
{
this._edades = new int[50];
this._sexos = new char[50];
this._cantHombres = 0;
this._cantMujeres = 0;
this._promedioEdadHombres = 0;
this._promedioEdadMujeres = 0;
this._edadMasJoven = 0;
}
public void PedirDatos()
{
Console.WriteLine("Ingrese edades: ");
for (int i = 0; i < this._edades.Length; i++)
{
Console.Write("Ingrese edad: "
// Declare a list of people and create some people objects
List<person> people = new List<person>();
for (int i = 0; i < 50; i++)
{
people.Add(new person(faker.Random.Int(0, 100), faker.Person.Gender));
}
// 1. How many men and women
int menCount = people.Count(x => x.sex == "Male");
int womenCount = people.Count(x => x.sex == "Female");
// 2. Average age by sex
double menAgeAvg = people.Where(x => x.sex == "Male").Average(x => x.age);
double womenAgeAvg = people.Where(x => x.sex == "Female").Average(x => x.age);
// 3. Youngest person
person youngest = people.OrderBy(x => x.age).First();
def promedio(edades, sexo):
total = 0
for i in edades:
total += i
return total / len(edades)
edades = [23, 12, 65, 43, 22, 13, 16, 24]
sexo = ['m', 'f', 'm', 'm', 'f', 'f', 'm', 'f']
promedio(edades, sexo)
public class Program
{
public static void Main()
{
int total = 50;
int[] edades = new int[total];
int[] sexos = new int[total];
int[] acumEdades = new int[2];
double[] promedios = new double[2];
int[] contador = new int[2];
int edadMasJoven = 120; // inicializamos en algo mayor a 100
for (int i = 0; i < edades.Length; i++)
{
edades[i] = 0;
}
for (int i = 0; i < total; i++)
{
Console.Write("Ingrese la edad: ");
edades[i] = int.Parse(Console.ReadLine());
Console.Write("Ingrese el sexo: ");
sexos[i] = int.Parse(Console.ReadLine());
acumEdades[sexos[i] - 1] += edades[i];
using System;
namespace Ejercicio11
{
public class Program
{
public static void Main(string[] args)
{
int[] edades = new int[50];
string[] sexos = new string[50];
int mujeres = 0;
int hombres = 0;
int sumaMujeres = 0;
int sumaHombres = 0;
double promedioMujeres;
double promedioHombres;
int edadMenor = 0;
Console.WriteLine("\n -----Ingrese los datos de la fiesta-----");
for (int i = 0; i < edades.Length; i++)
{
Console.Write("\nIngrese la edad: ");
edades[i] = Int32.Parse(Console.ReadLine());
Console.Write("Ingrese el sexo (Mujer/Hombre): ");
sexos[i] = Console.ReadLine();
if
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ejercicio03_05
{
class Program
{
static void Main(string[] args)
{
int[] numero = new int[10];
int i;
string mensaje = "";
for (i = 0; i < 10; i++)
{
Console.Write("ingrese un numero: ");
numero[i] = int.Parse(Console.ReadLine());
if (numero[i] % 3 == 0)
{
mensaje = mensaje + " " + numero[i];
}
if (numero[i] % 5 == 0)
{
mensaje = mensaje + " " + numero[i];
}
if (numero[i] % 5 != 0 & numero[i] % 3 != 0
void Main(string[] args)
{
int[] arreglo = new int[50];
string[] arreglo1 = new string[50];
int mujeres = 0;
int hombres = 0;
int promedioM = 0;
int promedioH = 0;
int menor = 0;
for (int i = 0; i < arreglo.Length; i++)
{
Console.WriteLine("Edad: ");
arreglo[i] = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Sexo: ");
arreglo1[i] = Console.ReadLine();
}
for (int i = 0; i < arreglo.Length; i++)
{
if (arreglo1[i] == "M")
{
promedioM = promedioM + arreglo[i];
hombres++;
}
else
{
promedioH
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int[] edades = { 20, 22, 10, 45, 66, 22, 12, 11, 34, 21, 22, 19, 23, 25, 20, 24, 14, 18, 27, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30 };
string[] sexos = { "M", "M", "F", "M", "M", "M", "F", "F", "F", "F", "M", "F", "F", "F
int[] edad = new int[50];
string[] sexo = new string[50];
int[] sexoNum = new int[2];
int[] sumaEdades = new int[2];
int promedio = 0;
int min = 0;
string minSexo = "";
int i = 0;
for(int i = 0; i < 50; i++)
{
Console.WriteLine("Escribe tu edad: ");
edad[i] = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Escribe tu sexo: ");
sexo[i] = Console.ReadLine();
//contador de hombres y mujeres
if(sexo[i].Equals("hombre"))
{
sexoNum[0]++;
}else{
sexoNum[1]++;
}
//suma de edades
if(sexo[i].Equals("hombre"))
{
sumaEdades[0] =
int[] edades = new int[50];
char[] sexos = new char[50];
void inicializarArreglos(int[] edades, char[] sexos)
{
for (int i = 0; i < edades.Length; i++)
{
edades[i] = new Random(i).Next(18,80);
sexos[i] = (new Random(i).Next(0,1) == 1)?'M':'F';
}
}
void mostrarArreglos(int[] edades, char[] sexos)
{
for (int i = 0; i < edades.Length; i++)
{
Console.WriteLine($"Persona {i + 1} tiene {edades[i]} años y es {sexos[i]}");
}
}
void calcularPromedios(int[] edades, char[] sexos)
{
double sumaEdadesHombres = 0;
double sumaEdadesMujeres = 0;
class Fiesta
{
private int[] edades;
private char[] sexos;
private int hombres;
private int mujeres;
private int promemale;
private int promefemale;
private int young;
public Fiesta()
{
edades = new int[50];
sexos = new char[50];
hombres = 0;
mujeres = 0;
promemale = 0;
promefemale = 0;
young = 1;
}
public void read_data()
{
int i;
for (i = 0; i < 50; i++)
{
Console.WriteLine("Dame la edad {0}", i + 1);
edades[i] = int.Parse(Console.ReadLine());
Console.WriteLine("Dame el sexo (H/M) {0}", i + 1);
sexos[i] = char.Parse(Console.ReadLine());
}
public class Person {
public string name {get; set;}
public int age {get; set;}
public string sex {get; set;}
public Person(string name, int age, string sex) {
this.name = name;
this.age = age;
this.sex = sex;
}
}
public List<Person> people = new List<Person>();
people.Add(new Person("Julio", 34, "M"));
people.Add(new Person("Armando", 34, "M"));
people.Add(new Person("Sara", 34, "F"));
people.Add(new Person("Jose", 34, "M"));
public List<Person> men = new List<Person>();
public List<Person> women = new List<Person>();
foreach (var person in people) {
if (person.sex == "M") {
men.Add(person);
}
if (person.sex == "F") {
women.Add(person);
int [] men_ages;
int [] woman_ages;
int number_of_men = 0;
int number_of_woman = 0;
double mean_men = 0;
double mean_woman = 0;
int younged_person = 0;
for (int i = 0; i < 50; i++){
int age = int.Parse(Console.ReadLine());
int gender = int.Parse(Console.ReadLine());
if (gender == 1){
men_ages[i] = age;
number_of_men++;
}else{
women_ages[i] = age;
number_of_woman++;
}
}
for (int j = 0; j < number_of_men; j++){
mean_men += men_ages[j];
}
mean_men = mean_men / number_of_men;
for (int j = 0; j < number_of_woman; j++){
mean_woman += women_ages
// C# program to find age of the youngest
// person in the family.
using System;
public class GFG{
// Function to find age of the youngest
// person among the family.
static int youngest(int[] age,
int n)
{
int min = 100;
for (int i = 0; i < n; i++)
{
if (age[i] < min)
min = age[i];
}
return min;
}
// Driver Code
public static void Main()
{
int n = 4;
int[] age = { 25, 28, 23, 25 };
Console.Write("Age of the youngest person is " +
youngest(age, n));
}
}
// This code is contributed by PrinciRaj1992
using System;
namespace ConsoleApp1
{
class Ejercicio3
{
private double[] edades;
private char[] sexo;
private int contador;
private int contadorMujeres;
public void LlenarDatos(int cantidad)
{
edades = new double[cantidad];
sexo = new char[cantidad];
for (int i = 0; i < cantidad; i++)
{
Console.WriteLine("Ingrese edad: ");
edades[i] = int.Parse(Console.ReadLine());
Console.WriteLine("Ingrese sexo: ");
sexo[i] = char.Parse(Console.ReadLine());
}
}
public void PromedioEdades()
{
double totalMujeres = 0;
double totalHombres = 0;
for (int i = 0; i < edades.Length; i++)
{
if (sexo
class fiesta
{
static void Main(string[] args)
{
int edad;
string sexo;
int[] edades = new int[50];
string[] sexos = new string[50];
int i = 0;
do
{
Console.Write("Ingrese su edad: ");
edad = int.Parse(Console.ReadLine());
edades[i] = edad;
Console.Write("Ingrese su sexo (F/M): ");
sexo = Console.ReadLine();
sexos[i] = sexo;
i = i + 1;
} while (i < 50);
int m = 0;
int f = 0;
for (i = 0; i < 50; i++)
{
if (sexos[i] == "F")
{
f = f + 1;
}
else
{
m = m + 1;
}
}
Console.Write
class Party
{
}
const int LONGITUD_ARREGLO = 50; // Numero de asistentes
const int EDAD_MAXIMA = 100; // Maxima edad aceptada
const int EDAD_MINIMA = 18; // Minima edad aceptada
int[] edades = new int[LONGITUD_ARREGLO];
char[] sexos = new char[LONGITUD_ARREGLO];
int numeroDeAsistentes = 0;
int edadMasJoven = EDAD_MAXIMA; // Inicializado con valor mas alto posible
int edadMasViejo = EDAD_MINIMA; // Inicializado con valor mas bajo posible
int edadPromedioHombres = 0;
int edadPromedioMujeres = 0;
int contadorHombres = 0;
int contadorMujeres = 0;
for (int i = 0; i < LONGITUD_ARREGLO; i++) {
Console.Write("Ingre
static void Main(string[] args)
{
int[] ages = new int[50];
char[] sex = new char[50];
int men = 0, women = 0, agesMen = 0, agesWomen = 0, youngest = 0;
for (int i = 0; i < 50; i++)
{
Console.Write("Ingresa tu edad: ");
ages[i] = Convert.ToInt32(Console.ReadLine());
while (ages[i] < 0 || ages[i] > 100)
{
Console.WriteLine("ingresa una edad valida: ");
ages[i] = Convert.ToInt32(Console.ReadLine());
}
Console.Write("Ingresa tu sexo: ");
sex[i] = Convert.ToChar(Console.ReadLine());
while (sex[i] != 'm' && sex[i] != 'f')
{
Console.Write("ingresa un sexo valido: ");
sex[i] = Convert.To
int[] ages = { 25, 22, 30, 29, 26, 22 };
string[] genders = { "M", "F", "M", "F", "M", "F" };
// 1. How many men and women attend
int sumMen = 0;
int sumWomen = 0;
for (int i = 0; i < ages.Length; i++) {
if (genders[i] == "M") {
sumMen++;
} else {
sumWomen++;
}
}
Console.WriteLine(sumMen);
Console.WriteLine(sumWomen);
// 2. Average ages by gender
// Sum ages
int sumAges = 0;
for (int i = 0; i < ages.Length; i++) {
sumAges = sumAges + ages[i];
}
// Avg age of men
int sumAgesMen = 0;
int qtyMen = 0;
for (int i = 0; i < ages.Length; i++) {
if (genders[i] == "M") {
sum
using System;
namespace OOP_Practica_2
{
class fiesta
{
private int hombre;
private int mujer;
private int sexo;
private int edad;
private int promedioedadhombre;
private int promedioedadmujer;
private int edadmasjoven;
public fiesta()
{
hombre = 0;
mujer = 0;
sexo = 0;
edad = 0;
promedioedadhombre = 0;
promedioedadmujer = 0;
edadmasjoven = 100;
}
public void solicitaramosdatos()
{
int[] sexo = new int[50];
int[] edad = new int[50];
for (int i = 0; i < 50; i++)
{
Console.WriteLine("Digite el sexo: ");
sexo[i] = int.Parse
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Edades
{
class Program
{
static void Main(string[] args)
{
int cantidad = 0;
int edad = 0;
int suma = 0;
int edadH = 0;
int edadM = 0;
int sumaH = 0;
int sumaM = 0;
int cantH = 0;
int cantM = 0;
string sexo = "";
string nombre = "";
bool condicion = true;
bool condicion2 = true;
int edadmenor = 0;
string nombreMenor = "";
string sexoMenor = "";
Console.Write("Ingrese cantidad de personas ");
cantidad = Convert.ToInt32(Console.ReadLine());
for (int i = 1; i <= cant
using System;
public class Multiplos
{
public static void Main()
{
int[] arreglo = new int[10];
int num;
int i;
int suma=0;
for(i=0; i<10; i++)
{
Console.WriteLine("Ingrese un numero de la posicion {0}: ",i);
num = Convert.ToInt32(Console.ReadLine());
arreglo[i]= num;
}
Console.WriteLine("\nLos multiplos de tres son: ");
for(i=0; i<10; i++)
{
if(arreglo[i]%3==0)
{
Console.WriteLine(arreglo[i]);
}
}
Console.WriteLine("\nLos multiplos de cinco son: ");
for(i=0; i<10; i++)
{
if(arreglo[i]%5==0)
using System;
using System.Linq;
public class Program
{
public static void Main()
{
int men = 0;
int women = 0;
int menAges = 0;
int womenAges = 0;
int menTotal = 0;
int womenTotal = 0;
int[] ages = new int[50];
string[] sex = new string[50];
for(var i=0; i<=49; i++){
ages[i] = i + 1;
if(i % 2 == 0){
sex[i] = "men";
menAges += ages[i];
menTotal++;
}else{
sex[i] = "women";
womenAges += ages[i];
womenTotal++;
}
}
Console.Write
class Fiesta
{
public int hombres = 0;
public int mujeres = 0;
public int edad_hombres = 0;
public int edad_mujeres = 0;
public int edad_mas_joven = 1000;
public int prom_hombres = 0;
public int prom_mujeres = 0;
public void datos()
{
int edad;
char sexo;
for (int i = 1; i < 51; i++)
{
Console.WriteLine("Ingrese su edad y su sexo: ");
edad = int.Parse(Console.ReadLine());
sexo = char.Parse(Console.ReadLine());
if (sexo == 'm')
{
hombres += 1;
edad_hombres += edad;
}
else if (sexo == 'f')
{
mujeres += 1;
edad_mujeres += edad;
int[] ages = new int[] { 18, 22, 19, 24, 33, 21, 26, 30, 41, 22, 35, 26, 28, 32, 35, 35, 29, 38, 45, 56,
30, 28, 30, 38, 32, 24, 50, 33, 31, 23, 29, 30, 25, 28, 28, 31, 33, 35, 27, 25,
18, 22, 19, 24, 33, 21, 26, 30, 41, 22, 35, 26, 28, 32, 35, 35, 29, 38, 45, 56,
30, 28, 30, 38, 32, 24, 50, 33, 31, 23, 29, 30, 25, 28, 28, 31, 33, 35, 27, 25
};
string[] genders = new string[] { "Hombre", "Mujer", "Hombre", "Mujer", "Hombre", "Hombre", "Hombre",
"Mujer", "Hombre", "Hombre", "Mujer", "Hombre
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int[] edades = new int[] { 20, 25, 23, 21, 18, 27, 31, 28, 33, 34, 35, 36, 38, 37, 45, 41, 42, 46, 54, 52, 51, 48, 58, 62, 65, 68, 70, 66, 80, 82, 84, 75, 72, 73, 74, 76, 78, 79, 87, 95, 99, 100, 94, 92, 91, 97, 93, 89, 90, 86, 83, 81, 85, 88, 96, 98 };
char[] sexo = new char[] { 'f', 'f', 'f', 'f', 'f', 'f', 'm', 'f', 'm', 'm', 'm', 'm', 'm', 'm', 'm', 'f', 'f', 'f', 'm', 'f',
using System;
namespace Clase2Ejercicio1
{
class Program
{
static void Main(string[] args)
{
Menu fiesta = new Menu();
fiesta.MenuPrincipal();
}
}
}
public int cantHombres(int[] hombres)
{
int h=0;
for (int i = 0; i < hombres.Length; i++)
{
h = h + hombres[i];
}
return h;
}
public int cantMujeres(int[] mujeres)
{
int m=0;
for (int i = 0; i < mujeres.Length; i++)
{
m = m + mujeres[i];
}
return m;
}
public float promHombres(int[] hombres)
{
int h = 0;
float prom = 0;
for (int i = 0; i < hombres.Length; i++)
{
h = h + hombres[i];
prom = h / hombres.Length;
}
return prom;
}
public float promMujeres(int[] mujeres)
{
using System;
namespace Funciones
{
class Program
{
static void Main(string[] args)
{
int[] edades = new int[50];
string[] sexos = new string[50];
int numHombres = 0;
int numMujeres = 0;
int sumaEdadesH = 0;
int sumaEdadesM = 0;
int edadJoven = 100;
for(int i = 0; i < 50; i++)
{
edades[i] = int.Parse(Console.ReadLine());
sexos[i] = Console.ReadLine();
if(sexos[i] == "H")
{
numHombres++;
sumaEdadesH += edades[i];
}
else
{
numMujeres++;
sumaEdadesM += edades[i];
}
if(edades[i] < edadJoven)
{
edad
edades = [20, 10, 30, 25, 15, 22, 20, 11, 13, 25]
sexos = ["m", "f", "m", "f", "m", "m", "m", "m", "f", "f"]
def get_avg_age(edades, sexos):
m_ages = 0
f_ages = 0
m_count = 0
f_count = 0
for i in range(len(edades)):
age = edades[i]
sex = sexos[i]
if sex == "m":
m_ages += age
m_count += 1
else:
f_ages += age
f_count += 1
return (m_ages/m_count, f_ages/f_count)
get_avg_age(edades, sexos)
static void Main(string[] args)
{
int[] ages = { 21, 23, 18, 22, 43, 27, 41, 40, 23, 19,
21, 23, 18, 22, 43, 27, 41, 40, 23, 19,
21, 23, 18, 22, 43, 27, 41, 40, 23, 19,
21, 23, 18, 22, 43, 27, 41, 40, 23, 19 };
char[] sex = { 'M', 'F', 'F', 'M', 'M', 'M', 'M', 'F', 'M', 'F',
'M', 'F', 'F', 'M', 'M', 'M', 'M', 'F', 'M', 'F',
'M', 'F', 'F', 'M', 'M', 'M', 'M', 'F', 'M', 'F',
'M', 'F', 'F', 'M', 'M', 'M', 'M', 'F', 'M', 'F' };
int countMales = 0;