viernes, 4 de junio de 2010

Regularización unidad 2

Pseudocodigo

1. inicio
total=0 double
peso double
limite double
Print "Introduce el limite de pesca: ", limite
do
{Print"Introduce el peso de la presa: ", peso
total=total+peso
Print "Total de kilos hasta el momento: ", total
}
while (total
Print "Limite excedido"

Fin


Código


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace joe_regu_2
{
class Program
{
static void Main(string[] args)
{
double total=0,peso;
double limite;
Console.Write("Introduce el limite de pesca: ");
limite = double.Parse(Console.ReadLine());
do
{
Console.WriteLine("\nIntroduce el peso cada presa: ");
peso = double.Parse(Console.ReadLine());
total = total + peso;
Console.Write("Total de kilos hasta el momento: {0}",total);

}
while(total

Console.Write("\nLimite excedido!!!");
Console.ReadKey();
}
}
}





miércoles, 2 de junio de 2010

practica 12 problema 2

Binary Writer

namespace Practica12problema2consola
{
class Program
{
static void Main(string[] args)
{
BinaryWriter bw = null;

try
{
bw=new BinaryWriter(new FileStream("c:\\PROM.txt",FileMode.Create,FileAccess.Write));
int N1, N2, N3, N4, N5, N6, N7, N8, N9, N10, N11, N12, N13, N14, N15, N16, N17, N18, N19, N20;


Console.WriteLine("Introduce el N1:");
N1=int.Parse(Console.ReadLine());
bw.Write(N1);
Console.WriteLine("Introduce el N2:");
N2 = int.Parse(Console.ReadLine());
bw.Write(N2);
Console.WriteLine("Introduce el N3:");
N3 = int.Parse(Console.ReadLine());
bw.Write(N3);
Console.WriteLine("Introduce el N4:");
N4 = int.Parse(Console.ReadLine());
bw.Write(N4);
Console.WriteLine("Introduce el N5:");
N5 = int.Parse(Console.ReadLine());
bw.Write(N5);
Console.WriteLine("Introduce el N6:");
N6 = int.Parse(Console.ReadLine());
bw.Write(N6);
Console.WriteLine("Introduce el N7:");
N7 = int.Parse(Console.ReadLine());
bw.Write(N7);
Console.WriteLine("Introduce el N8:");
N8 = int.Parse(Console.ReadLine());
bw.Write(N8);
Console.WriteLine("Introduce el N9:");
N9 = int.Parse(Console.ReadLine());
bw.Write(N9);
Console.WriteLine("Introduce el N10:");
N10 = int.Parse(Console.ReadLine());
bw.Write(N10);
Console.WriteLine("Introduce el N11:");
N11 = int.Parse(Console.ReadLine());
bw.Write(N11);
Console.WriteLine("Introduce el N12:");
N12 = int.Parse(Console.ReadLine());
bw.Write(N12);
Console.WriteLine("Introduce el N13:");
N13 = int.Parse(Console.ReadLine());
bw.Write(N13);
Console.WriteLine("Introduce el N14:");
N14 = int.Parse(Console.ReadLine());
bw.Write(N14);
Console.WriteLine("Introduce el N15:");
N15 = int.Parse(Console.ReadLine());
bw.Write(N15);
Console.WriteLine("Introduce el N16:");
N16 = int.Parse(Console.ReadLine());
bw.Write(N16);
Console.WriteLine("Introduce el N17:");
N17 = int.Parse(Console.ReadLine());
bw.Write(N17);
Console.WriteLine("Introduce el N18:");
N18 = int.Parse(Console.ReadLine());
bw.Write(N18);
Console.WriteLine("Introduce el N19:");
N19 = int.Parse(Console.ReadLine());
bw.Write(N19);
Console.WriteLine("Introduce el N20:");
N20 = int.Parse(Console.ReadLine());
bw.Write(N20);



}
catch(IOException e)
{
Console.WriteLine("Error:"+e.Message);
}

finally
{
if(bw !=null) bw.Close();
}
Console.ReadLine();


}
}
}

Binary Reader

namespace Practica12problema2consola
{
class Program
{
static void Main(string[] args)
{
BinaryWriter bw = null;

try
{
bw=new BinaryWriter(new FileStream("c:\\PROM.txt",FileMode.Create,FileAccess.Write));
int N1, N2, N3, N4, N5, N6, N7, N8, N9, N10, N11, N12, N13, N14, N15, N16, N17, N18, N19, N20;


Console.WriteLine("Introduce el N1:");
N1=int.Parse(Console.ReadLine());
bw.Write(N1);
Console.WriteLine("Introduce el N2:");
N2 = int.Parse(Console.ReadLine());
bw.Write(N2);
Console.WriteLine("Introduce el N3:");
N3 = int.Parse(Console.ReadLine());
bw.Write(N3);
Console.WriteLine("Introduce el N4:");
N4 = int.Parse(Console.ReadLine());
bw.Write(N4);
Console.WriteLine("Introduce el N5:");
N5 = int.Parse(Console.ReadLine());
bw.Write(N5);
Console.WriteLine("Introduce el N6:");
N6 = int.Parse(Console.ReadLine());
bw.Write(N6);
Console.WriteLine("Introduce el N7:");
N7 = int.Parse(Console.ReadLine());
bw.Write(N7);
Console.WriteLine("Introduce el N8:");
N8 = int.Parse(Console.ReadLine());
bw.Write(N8);
Console.WriteLine("Introduce el N9:");
N9 = int.Parse(Console.ReadLine());
bw.Write(N9);
Console.WriteLine("Introduce el N10:");
N10 = int.Parse(Console.ReadLine());
bw.Write(N10);
Console.WriteLine("Introduce el N11:");
N11 = int.Parse(Console.ReadLine());
bw.Write(N11);
Console.WriteLine("Introduce el N12:");
N12 = int.Parse(Console.ReadLine());
bw.Write(N12);
Console.WriteLine("Introduce el N13:");
N13 = int.Parse(Console.ReadLine());
bw.Write(N13);
Console.WriteLine("Introduce el N14:");
N14 = int.Parse(Console.ReadLine());
bw.Write(N14);
Console.WriteLine("Introduce el N15:");
N15 = int.Parse(Console.ReadLine());
bw.Write(N15);
Console.WriteLine("Introduce el N16:");
N16 = int.Parse(Console.ReadLine());
bw.Write(N16);
Console.WriteLine("Introduce el N17:");
N17 = int.Parse(Console.ReadLine());
bw.Write(N17);
Console.WriteLine("Introduce el N18:");
N18 = int.Parse(Console.ReadLine());
bw.Write(N18);
Console.WriteLine("Introduce el N19:");
N19 = int.Parse(Console.ReadLine());
bw.Write(N19);
Console.WriteLine("Introduce el N20:");
N20 = int.Parse(Console.ReadLine());
bw.Write(N20);



}
catch(IOException e)
{
Console.WriteLine("Error:"+e.Message);
}

finally
{
if(bw !=null) bw.Close();
}
Console.ReadLine();


}
}
}


practica 12 problema 1

Binary Writer

class Program
{
static void Main(string[] args)
{
double x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6;


FileStream f1 = new FileStream("c:\\Puntos.txt", FileMode.Create, FileAccess.Write);
BinaryWriter bw = new BinaryWriter(f1);

Console.WriteLine("Introduce Coordenadas Punto 1");
Console.Write("x1= ");
x1 = double.Parse(Console.ReadLine());

Console.Write("y1= ");
y1 = double.Parse(Console.ReadLine());

Console.WriteLine("Introduce Coordenadas Punto 2");
Console.Write("x2= ");
x2 = double.Parse(Console.ReadLine());

Console.Write("y2= ");
y2 = double.Parse(Console.ReadLine());


bw.Write(x1);
bw.Write(y1);
bw.Write(x2);
bw.Write(y2);

Console.WriteLine("Introduce Coordenadas Punto 3");
Console.Write("x3= ");
x3 = double.Parse(Console.ReadLine());

Console.Write("y3= ");
y3 = double.Parse(Console.ReadLine());

Console.WriteLine("Introduce Coordenadas Punto 4");
Console.Write("x4= ");
x4 = double.Parse(Console.ReadLine());

Console.Write("y4= ");
y4 = double.Parse(Console.ReadLine());

bw.Write(x3);
bw.Write(y3);
bw.Write(x4);
bw.Write(y4);

Console.WriteLine("Introduce Coordenadas Punto 5");
Console.Write("x5= ");
x5 = double.Parse(Console.ReadLine());

Console.Write("y5= ");
y5 = double.Parse(Console.ReadLine());

Console.WriteLine("Introduce Coordenadas Punto 6");
Console.Write("x6= ");
x6 = double.Parse(Console.ReadLine());

Console.Write("y6= ");
y6 = double.Parse(Console.ReadLine());

bw.Write(x5);
bw.Write(y5);
bw.Write(x6);
bw.Write(y6);



Console.ReadKey();


}
}
}


Binary Reader

class Program
{
static void Main(string[] args)
{
BinaryReader br = null;
try
{
if (File.Exists("c:\\puntos.txt"))
{
br = new BinaryReader(new FileStream("c:\\puntos.txt", FileMode.Open, FileAccess.Read));
double x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6;
double pendiente1, pendiente2, pendiente3;
double pmX1, pmX2, pmX3;
double pmY1, pmY2, pmY3;


x1 = br.ReadDouble();
y1 = br.ReadDouble();
x2 = br.ReadDouble();
y2 = br.ReadDouble();
x3 = br.ReadDouble();
y3 = br.ReadDouble();
x4 = br.ReadDouble();
y4 = br.ReadDouble();
x5 = br.ReadDouble();
y5 = br.ReadDouble();
x6 = br.ReadDouble();
y6 = br.ReadDouble();



Console.WriteLine("Coordenadas punto1:{0}\t{1}", x1, y1);
Console.WriteLine("Coordenadas punto2:{0}\t{1}", x2, y2);
Console.WriteLine("Coordenadas punto3:{0}\t{1}", x3, y3);
Console.WriteLine("Coordenadas punto4:{0}\t{1}", x4, y4);
Console.WriteLine("Coordenadas punto5:{0}\t{1}", x5, y5);
Console.WriteLine("Coordenadas punto6:{0}\t{1}", x6, y6);
Console.WriteLine("Puntos 1 y 2");
pendiente1 = (y2 - y1) / (x2 - x1);
pmX1 = (x1 + x2) / 2;
pmY1 = (y1 + y2) / 2;

Console.WriteLine("pendiente1: " +pendiente1);

Console.WriteLine("Punto medio X: " +pmX1);

Console.WriteLine("Punto medio Y: " + pmY1);

Console.WriteLine("Puntos 3 y 4");
pendiente2 = (y4 - y3) / (x4 - x3);
pmX2 = (x3 + x4) / 2;
pmY2 = (y3 + y4) / 2;

Console.WriteLine("pendiente2: " + pendiente2);

Console.WriteLine("Punto medio X: " + pmX2);

Console.WriteLine("Punto medio Y: " + pmY2);

Console.WriteLine("Puntos 5 y 6");
pendiente3 = (y6 - y5) / (x6 - x5);
pmX3 = (x5 + x6) / 2;
pmY3 = (y6 + y5) / 2;

Console.WriteLine("pendiente3: " + pendiente3);

Console.WriteLine("Punto medio X: " + pmX3);

Console.WriteLine("Punto medio Y: " + pmY3);


Console.ReadKey();




}
else
Console.WriteLine("no existe archivo");
}
catch (EndOfStreamException)
{
Console.WriteLine("fin de archivo ");
}
finally
{
if (br != null) br.Close();
}

Console.ReadKey();
}
}
}