3.-
7.-
using System;
namespace ConsoleApplication12
{
class Program
{
static void Main(string[] args)
{
int dado, t = 0;
double d1 = 0, d2 = 0, d3 = 0, d4 = 0, d5 = 0, d6 = 0;
char pulse;
Random rn = new Random();
Console.WriteLine("Para tirar el dado pulse t, para parar y ver las estadisticas p");
pulse = char.Parse(Console.ReadLine());
while(pulse=='t')
{
dado = rn.Next(1,6);
Console.WriteLine("{0}", dado);
switch(dado)
{
case 1: d1++;
break;
case 2:
d2++;
break;
case 3:
d3++;
break;
case 4:
d4++;
break;
case 5:
d5++;
break;
case 6:
d6++;
break;
}
t++;
pulse = char.Parse(Console.ReadLine());
}
Console.WriteLine("Las estadisticas son:");
Console.WriteLine("1 - {0}",d1/t);
Console.WriteLine("2 - {0}", d2 / t);
Console.WriteLine("3 - {0}", d3 / t);
Console.WriteLine("4 - {0}", d4 / t);
Console.WriteLine("5 - {0}", d5 / t);
Console.WriteLine("6 - {0}", d6 / t);
Console.ReadKey();
}
}
}
9.-
11.-
using System;
namespace ConsoleApplication14
{
class Program
{
static void dalelaVuelta(int num, ref string cadena)
{
int resto= num%10;
string auxr;
Console.Write(resto);
auxr = resto.ToString();
cadena = cadena + resto;
if(num>10)
{
dalelaVuelta(num / 10, ref cadena);
}
}
static string EsPalindromo(string n)
{
int cuenta=0;
string aux = n;
while (n.Length>1)
{
if(n[0]==n[n.Length-2])
{
cuenta++;
}
n=n.Remove(0, 1);
}
if(cuenta==(aux.Length/2))
{
return "si";
}
else
{
return "no";
}
}
static void Main(string[] args)
{
int n;
string cadena = " ";
Console.WriteLine("Introduzca el número");
n = int.Parse(Console.ReadLine());
dalelaVuelta(n, ref cadena);
Console.Write("\n");
Console.WriteLine("El numero introducido {0} es palindromo", EsPalindromo(cadena));
Console.ReadKey();
}
}
}
12.-
13.-
14.-
17.-
21.-
22.-
0 comentarios:
Publicar un comentario