Menú

Mostrar Mensajes

Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.

Mostrar Mensajes Menú

Temas - Noporfavor

#1
Hola,

me arreglado mas o menos con Sun Java Wireless Toolkit para programar en J2Me.

Les mostrare mi codigo:

Código: php

package anuMidSub;

import anuThreadSub.MessageReceiver;
import anuThreadSub.MessageSender;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import javax.microedition.io.Connector;
import javax.microedition.io.ServerSocketConnection;
import javax.microedition.io.SocketConnection;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Gauge;
import javax.microedition.lcdui.Item;
import javax.microedition.lcdui.ItemCommandListener;
import javax.microedition.lcdui.Spacer;
import javax.microedition.lcdui.StringItem;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.MIDlet;

/**
* @author Anuja
*/
public class Friends connecter extends MIDlet implements CommandListener, ItemCommandListener, Runnable {
    private Display display;
    private Form chatServerForm;
    private Command exitCmd;
    private StringItem ipStrItem;
    private StringItem startServerStrItem;
    private Command startCmd;
    private Form showIpForm;
    private Gauge gaugeItem;
    private Spacer spacerItem;
    private ServerSocketConnection serSocCon;
    private String deviceIp;
    private SocketConnection socCon;
    private DataInputStream is;
    private DataOutputStream os;
    private Form srvChattingFrm;
    private TextField chatTxtFld;
    private Alert infoAlert;
    private Command sendCmd;
    private String srvChatMsg;
    private MessageSender msgSenderClass;

    public void startApp() {
        display = Display.getDisplay(this);

        //-------------------------- Start chat server form --------------------
        chatServerForm = new Form("Chat Server");

        // \t use for getting tab space
        startServerStrItem = new StringItem("Start Chat Server \t", "Start", Item.BUTTON);
        chatServerForm.append(startServerStrItem);

        startCmd = new Command("Start", Command.ITEM, 8);
        startServerStrItem.setDefaultCommand(startCmd);
        startServerStrItem.setItemCommandListener(this);

        // Provide space as developer defined minWidth and minHeight
        spacerItem = new Spacer(200, 50);
        chatServerForm.append(spacerItem);

        // Continuous-running state of a non-interactive Gauge with indefinite range
        gaugeItem = new Gauge("Waiting for client... \n", false, Gauge.INDEFINITE, Gauge.CONTINUOUS_RUNNING);
        // Set layout position for this gauge item
        gaugeItem.setLayout(Item.LAYOUT_CENTER);
        chatServerForm.append(gaugeItem);

        exitCmd = new Command("Exit", Command.EXIT, 7);
        chatServerForm.addCommand(exitCmd);

        chatServerForm.setCommandListener(this);
        display.setCurrent(chatServerForm);

        // ----------------------- Show IP form --------------------------------

        showIpForm = new Form("Chat Server");
        ipStrItem = new StringItem("Client must connect to this IP: \n\n", "My IP \n");
        ipStrItem.setLayout(Item.LAYOUT_CENTER);

        // setFont() sets the application's preferred font for rendering this StringItem.
        ipStrItem.setFont(Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_BOLD, Font.SIZE_LARGE));
        showIpForm.append(ipStrItem);

        showIpForm.addCommand(exitCmd);
        showIpForm.setCommandListener(this);

        //------------------- Server chatting form -----------------------------

        srvChattingFrm = new Form("Server Chatting...");
        chatTxtFld = new TextField("Enter Chat", "", 160, TextField.ANY);
        srvChattingFrm.append(chatTxtFld);

        sendCmd = new Command("Send", Command.OK, 4);
        srvChattingFrm.addCommand(sendCmd);
        srvChattingFrm.addCommand(exitCmd);
        srvChattingFrm.setCommandListener(this);
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }

    public void commandAction(Command c, Displayable d) {
        if(c == exitCmd){
            notifyDestroyed();
        }else if(c == sendCmd){
            // getString() gets the contents of the TextField as a string value.
            srvChatMsg = chatTxtFld.getString();
            // Send the chat to send() in MessageSender class
            msgSenderClass.send(srvChatMsg);
        }
    }

    public void commandAction(Command c, Item item) {
        if(c == startCmd){
            new Thread(this).start();
            //Alert alert = new Alert("Working");
            //display.setCurrent(alert);
        }
    }

    public void run() {
        System.out.println("Runnig");
        try {
            // ServerSocketConnection interface defines the server socket stream connection.
            // Create the server listening socket for port 60000
            serSocCon = (ServerSocketConnection) Connector.open("socket://:60000");
            System.out.println("Open the socket...");
        } catch (IOException ex) {
            ex.printStackTrace();
        }

        try {
            // Gets the local address to which the socket is bound.
            // The host address(IP number) that can be used to connect to this end of the socket connection from an external system.
            deviceIp = serSocCon.getLocalAddress();
            System.out.println("Get device IP...");
        } catch (IOException ex) {
            ex.printStackTrace();
        }

        showIpForm.append(deviceIp);
        display.setCurrent(showIpForm);

        try {
            System.out.println("Waiting for client request...");
            // Wait for a connection.
            // A socket is accessed using a generic connection string with an explicit host and port number.
            // acceptAndOpen() inherited from interface javax.microedition.io.StreamConnectionNotifier
            // Returns a StreamConnection object that represents a server side socket connection.
            // The method blocks until a connection is made.
            socCon = (SocketConnection) serSocCon.acceptAndOpen();
            System.out.println("Accepted and open the connection...");
        } catch (IOException ex) {
            ex.printStackTrace();
        }

        try {
            // InputStream is an abstract class and it is the superclass of all classes representing an input stream of bytes.
            // openDataInputStream() inherited from interface javax.microedition.io.InputConnection
            // openDataInputStream() Open and return an input stream for a connection.
            is = socCon.openDataInputStream();
        } catch (IOException ex) {
            ex.printStackTrace();
        }

        try {
            // OutputStream is an abstract class and it is the superclass of all classes representing an output stream of bytes.
            // An output stream accepts output bytes and sends them to some sink.
            // openDataOutputStream() inherited from interface javax.microedition.io.OutputConnection
            // openDataOutputStream() open and return a data output stream for a connection.
            os = socCon.openDataOutputStream();
        } catch (IOException ex) {
            ex.printStackTrace();
        }

        // Send our chat to other party
        // Initialization part have to doen begining caz Send command want to use the send() in MessageSender class
        // We pass the TextField as argement caz we want to clear the field before sent another chat
        msgSenderClass = new MessageSender(os, chatTxtFld);
        msgSenderClass.start();

        //clear();

        // Receive other party's chat and load our chatting interface
        MessageReceiver msgReceiverClass = new MessageReceiver(is, srvChattingFrm);
        msgReceiverClass.start();

        infoAlert = new Alert("Client connected successfully.");
        display.setCurrent(infoAlert, srvChattingFrm);
    }

    public void clear(){
        chatTxtFld.setString("");
        //msgSenderClass.start();
    }

    public TextField getChatTxtFld() {
        return chatTxtFld;
    }   
}


Porque cuando le doy a build me larga error:

Unable to create MIDlet Friendsconnecter
java.lang.ClassNotFoundException: Friendsconnecter
   at com.sun.midp.midlet.MIDletState.createMIDlet(+29)
   at No tienes permitido ver los links. Registrarse o Entrar a mi cuenta(+22)

Saludos y gracias :)
#2
Dudas y pedidos generales / Programar en J2ME
Marzo 27, 2017, 02:22:58 PM
Hola,

instale Eclipse con J2Me. Queria saber de donde saco los elementos visuales para agregarlos a un proyecto.

Gracias
#3
Hola,

cómo puedo abrir los puertos de un celular que tiene internet movil?


Gracias y saludos
#4
Dudas y pedidos generales / Hackear un servidor
Marzo 07, 2017, 01:05:59 PM
Hola,

tenia una duda:

Si yo tengo un servidor de chat... alguien podria hackear mediante el mi computadora?
Esta pregunta me vino con la charla con un companero mio que es programador de C#. El me conto que und servidor es lo mismo que una computadora.

Entonces... podria hackear alguien mi computadora mediante un servidor de chat que pongo online?

Gracias y saludos
#5
Dudas y pedidos generales / FileGraber en ProgDVB
Febrero 25, 2017, 02:26:49 PM
Hola,

suponiendo que existiera ese programa en java....

Funcionaria teniendo mi celular recepcion GPRS, GPS, y tal vez WAP?

Gracias y saludos
#6
Dudas y pedidos generales / Encriptar ip con C#
Febrero 23, 2017, 08:32:38 AM
Hola,

me estoy volviendo loco con este problema:

Resulta que quiero encriptar mi ip. Pero hasta ahora solo lei que se puede encriptar textos.

Por ejemplo:

Código: csharp

public static string Encriptar(this string _cadenaAencriptar)
        {
            string result = string.Empty;
            byte[] encryted = System.Text.Encoding.Unicode.GetBytes(_cadenaAencriptar);
            result = Convert.ToBase64String(encryted);
            return result;
        }


Ahora bien; supongamos que convierto la ip en string y del string lo encripto. Lo unico que logro es encriptar un texto y no la ip.

Yo he visto usuarios en minicraft que cuando el administrador le hizo un whois en vez de ver un formato ip vio un texto cualquiera tipo: "Chinga tu madre".
Como hacen estos para cambiar el valor de una ip y aun asi poder conectarse?

Gracias y saludos
#7
Hola,
tengo una duda. Pero antes necesito que les hechen un vistazo a esto:

No tienes permitido ver los links. Registrarse o Entrar a mi cuenta

En especial a donde dice:
Name: onconnected
Type: function
Return type: bool
Argument 1 type: function

Como es un bool, no lo puedo combinar con while?
Es decir algoasi como: while (onconnected)

Gracias y saludos
#8
Dudas y pedidos generales / Analisis de Sb0t 5.36
Febrero 13, 2017, 04:45:54 PM
Hola,

les quiero dejar un pedazo de codigo llamado Bans.cs:

Código: csharp

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml;
using System.Net;
using iconnect;

namespace commands
{
    class Bans
    {
        private class Item
        {
            public IPAddress IP { get; set; }
            public Guid Guid { get; set; }
            public uint Time { get; set; }
            public BanDuration Duration { get; set; }
            public String Name { get; set; }
        }

        public static void AddBan(IUser client, BanDuration duration)
        {
            if (list.Find(x => x.IP.Equals(client.ExternalIP) || x.Guid.Equals(client.Guid)) == null)
            {
                list.Add(new Item
                {
                    Guid = client.Guid,
                    IP = client.ExternalIP,
                    Time = Server.Time,
                    Duration = duration,
                    Name = client.Name
                });

                Save();
            }
        }

        public static void RemoveBan(String name)
        {
            list.RemoveAll(x => x.Name == name);
            Save();
        }

        private static List<Item> list { get; set; }

        public static void Tick(uint time)
        {
            for (int i = (list.Count - 1); i > -1; i--)
            {
                Item m = list[i];

                if ((time - m.Time) > (uint)m.Duration)
                {
                    list.RemoveAt(i);
                    Server.Print(Template.Text(Category.Timeouts, 2).Replace("+n", m.Name), true);

                    Server.Users.Banned(x =>
                    {
                        if (x.ExternalIP.Equals(m.IP) || x.Guid.Equals(m.Guid))
                            x.Unban();
                    });
                }
            }
        }

        public static void Clear()
        {
            list = new List<Item>();
            Save();
        }

        private static void Save()
        {
            XmlDocument xml = new XmlDocument();
            xml.PreserveWhitespace = true;
            xml.AppendChild(xml.CreateXmlDeclaration("1.0", null, null));
            XmlNode root = xml.AppendChild(xml.CreateElement("bans"));

            foreach (Item i in list)
            {
                XmlNode item = root.OwnerDocument.CreateNode(XmlNodeType.Element, "item", root.BaseURI);
                root.AppendChild(item);
                XmlNode ip = item.OwnerDocument.CreateNode(XmlNodeType.Element, "ip", item.BaseURI);
                item.AppendChild(ip);
                ip.InnerText = i.IP.ToString();
                XmlNode guid = item.OwnerDocument.CreateNode(XmlNodeType.Element, "guid", item.BaseURI);
                item.AppendChild(guid);
                guid.InnerText = i.Guid.ToString();
                XmlNode time = item.OwnerDocument.CreateNode(XmlNodeType.Element, "time", item.BaseURI);
                item.AppendChild(time);
                time.InnerText = i.Time.ToString();
                XmlNode duration = item.OwnerDocument.CreateNode(XmlNodeType.Element, "duration", item.BaseURI);
                item.AppendChild(duration);
                duration.InnerText = ((uint)i.Duration).ToString();               
                XmlNode name = item.OwnerDocument.CreateNode(XmlNodeType.Element, "name", item.BaseURI);
                item.AppendChild(name);
                name.InnerText = i.Name;
            }

            try { xml.Save(Path.Combine(Server.DataPath, "bans.xml")); }
            catch { }
        }

        public static void Load()
        {
            list = new List<Item>();

            try
            {
                XmlDocument xml = new XmlDocument();
                xml.PreserveWhitespace = true;
                xml.Load(Path.Combine(Server.DataPath, "bans.xml"));

                XmlNodeList nodes = xml.GetElementsByTagName("item");

                foreach (XmlElement e in nodes)
                    list.Add(new Item
                    {
                        IP = IPAddress.Parse(e.GetElementsByTagName("ip")[0].InnerText),
                        Guid = new Guid(e.GetElementsByTagName("guid")[0].InnerText),
                        Time = uint.Parse(e.GetElementsByTagName("time")[0].InnerText),
                        Duration = e.GetElementsByTagName("duration")[0].InnerText == "600" ? BanDuration.Ten : BanDuration.Sixty,
                        Name = e.GetElementsByTagName("name")[0].InnerText
                    });
            }
            catch { }
        }
    }

    enum BanDuration : uint
    {
        Ten = 600,
        Sixty = 3600
    }
}


En la linea 34 se puede ver:

public IPAddress IP { get; set; }

Yo creo que se saca la ip y se coloca. Estoy en lo correcto?

Gracias y saludos
#9
Hola,

De aca se puede descargar Firefox para Sony Ericsson K750i:
No tienes permitido ver los links. Registrarse o Entrar a mi cuenta
Pero como lo instalo? En la computadora, cuando abro el archivo .rar, aparte de salir otros archivos, me sale un cantidad impresionante de archivos .class. Solamente los tengo que copiar al celular?

Gracias y saludos
#10
Dudas y pedidos generales / GTA San Andreas no abre
Enero 10, 2017, 01:51:44 PM
Hola,

el GTA San Andreas no me abre. Ya probe muchas cosas del internet pero no funciona. Como se abre el GTA San Andreas?

Gracias y saludos
#11
Hola,

como puedo hacer un programa que se conecte a un telefono y lo llame con C#?

Gracias
#12
Hola,

trate de saber el sistema operativo por medio de la ip con NMap.
Pero NMap me dice que no encontro por lo menos 1 puerto abierto y uno cerrado. Pero yo se que la ip por medio de la cual trato de saber el
sistema operativo tiene un puerto abierto, a saber, el 54321.

Aqui la imgaen:


Me ayudan?

Gracias y saludos
#13
Hola,
En el NetBus 1.7 esta el patch.exe.
Aqui les dejo el analisis por los antivirus: No tienes permitido ver los links. Registrarse o Entrar a mi cuenta

Hay gente que lograron hacerlo indetectable por muchos antivirus. Pero como?
Camuflandolo con una imagen? Usando Crypters y Binders?

Como lo puedo hacer yo?

Gracias y saludos
#14
Hola,

Virus hay muchos. Pero me podrian recomdar uno que pueda probar en mi otra computadora. Osea un virus cliente en la computadora victima que reciba ordenes del virus que da comandos. Alguna recomendacion?

Gracias y saludos
#15
Hola,

antes de la preguntas, el codigo:

Código: php

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using System.Threading;
using System.Net;
using System.Net.Sockets;
using System.IO;
using System.Runtime.InteropServices;

namespace Bot_client_ares_ejemplo_Source
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        //
        public Socket Socket;
        public System.Net.Sockets.NetworkStream Stream;
        //
        private void Form1_Load(object sender, EventArgs e)
        {

        }
        //
       
        //
        public byte[] MSG_CHAT_CLIENT_LOGIN()
        {
            //Aclaracion Este codigo es de mi autoridad 100% - ҳ√~м-[λ]-u-яí


            List<byte> buffer = new List<byte>();
            buffer.AddRange(new byte[] {//nueva cadena de bytes
            2,//id 2
            });
            buffer.AddRange(Guid.NewGuid().ToByteArray()); //guid 16 bytes
            buffer.AddRange(BitConverter.GetBytes(Convert.ToInt16(666))); //Numero de archivos
            buffer.AddRange(new byte[] {
            0,//Null 1byte
            });
            buffer.AddRange(BitConverter.GetBytes(Convert.ToInt16(5555))); //puerto DC
            buffer.AddRange(new byte[] {//nueva cadena de bytes
            0,0,0,0,//Nodos ip. 4bytes
            0,0,//Nodos puerto 2 bytes
            0,0,0,0,//4bytes Null.
            });
            buffer.AddRange(Encoding.UTF8.GetBytes("Nick"));//Nick x bytes
            buffer.AddRange(new byte[] {
            0,//Null 1byte
            });
            buffer.AddRange(Encoding.UTF8.GetBytes("?"));//cliente version xbyte
            buffer.AddRange(new byte[] {//nueva cadena de bytes
            0,//1byte Null.
            127,0,0,1,//Local IpAdress 4 bytes
            6,6,6,6,//External IpAdress Null. 4bytes
            0,//client features 1 byte
            0,//current upload 1byte
            0,//maximum uploads allowed 1byte
            0,//current queued users
            20,1,69,//User años 1byte, User sexo 1byte, User country 1byte

            });
            buffer.AddRange(Encoding.UTF8.GetBytes("Ares"));//User location xbyte
            buffer.AddRange(new byte[] {
            0,//Null 1byte
            });
            buffer.InsertRange(0, BitConverter.GetBytes(Convert.ToInt16(buffer.Count - 1)));
            return buffer.ToArray();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            ConectarB0t(System.Net.IPAddress.Parse("185.61.138.205"), 54321);
        }

        //
        public void ConectarB0t(IPAddress ip, int puerto)
        {
            Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            label1.Text = " Conectando, por favor espera..." + Environment.NewLine;

            try
            {
                Socket.Connect(new IPEndPoint(ip, Convert.ToInt32(puerto)));
            }
            catch (Exception ex)
            {

            }
            if (Socket.Connected == true)
            {
                label1.Text = "Conectando, iniciando protocolo...." + Environment.NewLine;

                Socket.Send(MSG_CHAT_CLIENT_LOGIN());

                label1.Text = "Conectando, Login Aceptado...." + Environment.NewLine;
            }
            else
            {


            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Socket.Disconnect(false);
            //
            label1.Text = "Desconectado";
        }
    }
}


Queria analiza con vosotros la linea 55:

buffer.AddRange(Encoding.UTF8.GetBytes("Nick"));//Nick x bytes

Dejenme saber si lo entendi bien:
Se codifica Nick osea se abstrae para construir un mayor entendimiento de las fuerzas que intervienen?

O alguien me puede ayudar, si lo entendi mal, a entender la linea 55 en palabras que un aprendiz pueda entender?

Gracias y saludos
#16
Hola a todos,
Como siempre, antes de las preguntas mostraré el código.
Sb0t 5.31/core/AresClient.cs:

Código: php

using System;
using System.Collections.Generic;
using System.Collections.Concurrent;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
using iconnect;

namespace core
{
    class AresClient : IClient, IUser, IQuarantined
    {
        public uint LastScribble { get; set; }
        public bool Ares { get; set; }
        public bool IsCbot { get; set; }
        public ushort ID { get; private set; }
        public IPAddress ExternalIP { get; set; }
        public String DNS { get; set; }
        public bool LoggedIn { get; set; }
        public ulong Time { get; set; }
        public Guid Guid { get; set; }
        public ushort FileCount { get; set; }
        public ushort DataPort { get; set; }
        public IPAddress NodeIP { get; set; }
        public ushort NodePort { get; set; }
        public String OrgName { get; set; }
        public String Version { get; set; }
        public IPAddress LocalIP { get; set; }
        public bool Browsable { get; set; }
        public byte CurrentUploads { get; set; }
        public byte MaxUploads { get; set; }
        public byte CurrentQueued { get; set; }
        public byte Age { get; set; }
        public byte Sex { get; set; }
        public byte Country { get; set; }
        public String Region { get; set; }
        public Encryption Encryption { get; set; }
        public bool FastPing { get; set; }
        public bool Ghosting { get; set; }
        public uint Cookie { get; set; }
        public List IgnoreList { get; set; }
        public bool CustomClient { get; set; }
        public List SharedFiles { get; set; }
        public List CustomClientTags { get; set; }
        public bool VoiceChatPublic { get; set; }
        public bool VoiceChatPrivate { get; set; }
        public bool VoiceOpusChatPublic { get; set; }
        public bool VoiceOpusChatPrivate { get; set; }
        public List VoiceChatIgnoreList { get; set; }
        public bool WebClient { get; private set; }
        public bool Owner { get; set; }
        public bool IsHTML { get; private set; }
        public bool Captcha { get; set; }
        public String CaptchaWord { get; set; }
        public byte[] OrgAvatar { get; set; }
        public uint JoinTime { get; private set; }
        public ulong IdleStart { get; set; }
        public bool Quarantined { get; set; }
        public bool IsLeaf { get; set; }
        public ILink Link { get { return new UserLinkCredentials(); } }
        public byte[] Password { get; set; }
        public bool SupportsHTML { get; set; }
        public bool IsWebWorker { get; set; }
        public IPEndPoint LocalEP { get; set; }

        public bool BlockCustomNames { get; set; }

        public IFont Font { get; set; }

        public Socket Sock { get; set; }
        public IPAddress SocketAddr { get; set; }
        public bool HasSecureLoginAttempted { get; set; }
        public FloodRecord FloodRecord { get; private set; }
        public bool AvatarReceived { get; set; }
        public ulong AvatarTimeout { get; set; }
        public bool DefaultAvatar { get; set; }

        private List data_in = new List();
        private ConcurrentQueue data_out = new ConcurrentQueue();
        private int socket_health = 0;
        private byte[] avatar = new byte[] { };
        private String personal_message = String.Empty;
        private ILevel _level = ILevel.Regular;
        private String _name=String%2EEmpty%3B
        private ushort _vroom = 0;
        private bool _cloaked = false;
        private String _customname=String%2EEmpty%3B

        public UserScribbleRoomObject ScribbleRoomObject = new UserScribbleRoomObject();

        public AresClient(Socket sock, ulong time, ushort id)
        {
            this.OrgAvatar = new byte[] { };
            this.ID = id;
            this.Sock = sock;
            this.Sock.Blocking = false;
            this.Time = time;
            this.SocketAddr = ((IPEndPoint)this.Sock.RemoteEndPoint).Address;
            this.ExternalIP = ((IPEndPoint)this.Sock.RemoteEndPoint).Address;
            this.LocalEP = (IPEndPoint)this.Sock.LocalEndPoint;
            this.Cookie = AccountManager.NextCookie;
            this.Encryption = new core.Encryption { Mode = EncryptionMode.Unencrypted };
            this.Version = String.Empty;
            this.IgnoreList = new List();
            this.SharedFiles = new List();
            this.CustomClientTags = new List();
            this.VoiceChatIgnoreList = new List();
            this.CaptchaWord = String.Empty;
            this.Captcha = !Settings.Get("captcha");
            this.JoinTime = Helpers.UnixTime;
            this.FloodRecord = new core.FloodRecord();
            this.AvatarTimeout = time;
            this.Font = new AresFont();
            Dns.BeginGetHostEntry(this.ExternalIP, new AsyncCallback(this.DnsReceived), null);
           // this.DNS = "unknown";
        }

        public void SendHTML(String text)
        {
            if (this.SupportsHTML)
                this.SendPacket(TCPOutbound.HTML(text));
        }

        public void Release()
        {
            this.Unquarantine();
        }

        public void SetLevel(ILevel level)
        {
            if (!this.LoggedIn)
                return;

            this.Registered = true;

            if (this.Quarantined)
                this.Unquarantine();

            this.Captcha = true;
            this.Level = level;
        }

        public void Scribble(String sender, byte[] img, int height)
        {
            List b = new List(img);

            if (b.Count  4000)
                {
                    p.Add(b.GetRange(0, 4000).ToArray());
                    b.RemoveRange(0, 4000);
                }

                if (b.Count > 0)
                    p.Add(b.ToArray());

                for (int i = 0; i < p.Count; i++)
                {
                    if (i == 0)
                        this.SendPacket(TCPOutbound.CustomData(this, sender, "cb0t_scribble_first", p[i]));
                    else if (i == (p.Count - 1))
                        this.SendPacket(TCPOutbound.CustomData(this, sender, "cb0t_scribble_last", p[i]));
                    else
                        this.SendPacket(TCPOutbound.CustomData(this, sender, "cb0t_scribble_chunk", p[i]));
                }
            }
        }

        public void Nudge(String sender)
        {
            byte[] buf = Encoding.UTF8.GetBytes("0" + sender);
            buf = Crypto.e67(buf, 1488);
            buf = Encoding.Default.GetBytes(Convert.ToBase64String(buf));
            this.SendPacket(TCPOutbound.CustomData(this, sender, "cb0t_nudge", buf));
        }

        private bool _muzzled;
        public bool Muzzled
        {
            get { return this._muzzled; }
            set
            {
                this._muzzled = value;

                if (ServerCore.Linker.Busy && this.LoggedIn && ServerCore.Linker.LoginPhase == LinkLeaf.LinkLogin.Ready)
                    ServerCore.Linker.SendPacket(LinkLeaf.LeafOutbound.LeafUserUpdated(ServerCore.Linker, this));
            }
        }

        private bool _registered;
        public bool Registered
        {
            get { return this._registered; }
            set
            {
                this._registered = value;

                if (ServerCore.Linker.Busy && this.LoggedIn && ServerCore.Linker.LoginPhase == LinkLeaf.LinkLogin.Ready)
                    ServerCore.Linker.SendPacket(LinkLeaf.LeafOutbound.LeafUserUpdated(ServerCore.Linker, this));
            }
        }

        private bool _idled;
        public bool Idled
        {
            get { return this._idled; }
            set
            {
                this._idled = value;

                if (ServerCore.Linker.Busy && this.LoggedIn && ServerCore.Linker.LoginPhase == LinkLeaf.LinkLogin.Ready)
                    ServerCore.Linker.SendPacket(LinkLeaf.LeafOutbound.LeafUserUpdated(ServerCore.Linker, this));
            }
        }

        public bool Idle { get { return this.Idled; } }

        public void Unquarantine()
        {
            this.LoggedIn = false;
            this.Quarantined = false;

            if (ServerCore.Linker.Busy && ServerCore.Linker.LoginPhase == LinkLeaf.LinkLogin.Ready)
                ServerCore.Linker.SendPacket(LinkLeaf.LeafOutbound.LeafJoin(ServerCore.Linker, this));

            Helpers.FakeRejoinSequence(this, true);
        }

        public String CustomName
        {
            get
            {
                if (!Settings.Get("customnames"))
                    return String.Empty;

                return this._customname;
            }
            set
            {
                this._customname=value == null ? String.Empty : value;

                if (ServerCore.Linker.Busy && ServerCore.Linker.LoginPhase == LinkLeaf.LinkLogin.Ready)
                    ServerCore.Linker.SendPacket(LinkLeaf.LeafOutbound.LeafCustomName(ServerCore.Linker, this));
            }
        }

        public void Ban()
        {
            if (!this.Owner)
                BanSystem.AddBan(this);

            this.Disconnect();
        }

        public void PM(String sender, String text)
        {
            int len = Encoding.UTF8.GetByteCount(sender);

            if (len >= 2 && len  0 && len  0)
                    if (!this.data_out.TryDequeue(out buf))
                        break;

                this.SendPacket(TCPOutbound.Redirect(this, room));
                this.Disconnect();
            }
        }

        public void RestoreAvatar()
        {
            if (this.rest_av != null)
                this.OrgAvatar = this.rest_av;

            this.Avatar = this.OrgAvatar;
        }

        public void SendEmote(String text)
        {
            if (!String.IsNullOrEmpty(text) && !this.Quarantined)
            {
                UserPool.AUsers.ForEachWhere(x => x.SendPacket(TCPOutbound.Emote(x, this.Name, text)),
                    x => x.LoggedIn && x.Vroom == this.Vroom && !x.IgnoreList.Contains(this.Name) && !x.Quarantined);

                UserPool.WUsers.ForEachWhere(x => x.QueuePacket(ib0t.WebOutbound.EmoteTo(x, this.Name, text)),
                    x => x.LoggedIn && x.Vroom == this.Vroom && !x.IgnoreList.Contains(this.Name) && !x.Quarantined);

                if (ServerCore.Linker.Busy && ServerCore.Linker.LoginPhase == LinkLeaf.LinkLogin.Ready)
                    ServerCore.Linker.SendPacket(LinkLeaf.LeafOutbound.LeafEmoteText(ServerCore.Linker, this.Name, text));
            }
        }

        public void SendText(String text)
        {
            if (!String.IsNullOrEmpty(text) && !this.Quarantined)
            {
                UserPool.AUsers.ForEachWhere(x => x.SendPacket((String.IsNullOrEmpty(this.CustomName) || x.BlockCustomNames) ?
                    TCPOutbound.Public(x, this.Name, text) : TCPOutbound.NoSuch(x, this.CustomName + text)),
                    x => x.LoggedIn && x.Vroom == this.Vroom && !x.IgnoreList.Contains(this.Name) && !x.Quarantined);

                UserPool.WUsers.ForEachWhere(x => x.QueuePacket(String.IsNullOrEmpty(this.CustomName) ?
                    ib0t.WebOutbound.PublicTo(x, this.Name, text) : ib0t.WebOutbound.NoSuchTo(x, this.CustomName + text)),
                    x => x.LoggedIn && x.Vroom == this.Vroom && !x.IgnoreList.Contains(this.Name) && !x.Quarantined);

                if (ServerCore.Linker.Busy && ServerCore.Linker.LoginPhase == LinkLeaf.LinkLogin.Ready)
                    ServerCore.Linker.SendPacket(LinkLeaf.LeafOutbound.LeafPublicText(ServerCore.Linker, this.Name, text));
            }
        }

        public void Topic(String text)
        {
            if (text != null)
                if (Encoding.UTF8.GetByteCount(text)  x.SendPacket(TCPOutbound.Part(x, this)),
                        x => x.LoggedIn && x.Vroom == this.Vroom && !x.Quarantined);

                    UserPool.WUsers.ForEachWhere(x => x.QueuePacket(ib0t.WebOutbound.PartTo(x, this.Name)),
                        x => x.LoggedIn && x.Vroom == this.Vroom && !x.Quarantined);
                }
                else Helpers.UncloakedSequence(this);
            }
        }

        public String Name
        {
            get { return this._name; }
            set
            {
                if (this.SocketConnected && Helpers.NameAvailable(this, value))
                    if (!this.LoggedIn)
                        this._name=value%3B
                    else
                    {
                        if (this.Quarantined)
                            return;

                        this.LoggedIn = false;

                        if (!this.Cloaked)
                        {
                            LinkLeaf.LinkUser other = null;

                            if (ServerCore.Linker.Busy)
                                foreach (LinkLeaf.Leaf leaf in ServerCore.Linker.Leaves)
                                {
                                    other = leaf.Users.Find(x => x.Vroom == this.Vroom && x.name=%3D this.Name && !x.Link.Visible);

                                    if (other != null)
                                    {
                                        other.LinkCredentials.Visible = true;
                                        break;
                                    }
                                }

                            UserPool.AUsers.ForEachWhere(x => x.SendPacket(other == null ? TCPOutbound.Part(x, this) : TCPOutbound.UpdateUserStatus(x, other)),
                                x => x.LoggedIn && x.Vroom == this.Vroom && !x.Quarantined);

                            UserPool.WUsers.ForEachWhere(x => x.QueuePacket(other == null ? ib0t.WebOutbound.PartTo(x, this.Name) : ib0t.WebOutbound.UpdateTo(x, other.Name, other.Level)),
                                x => x.LoggedIn && x.Vroom == this.Vroom && !x.Quarantined);
                        }

                        String current = this._name;
                        this._name=value%3B
                        Helpers.FakeRejoinSequence(this, false);
                       
                        if (ServerCore.Linker.Busy && ServerCore.Linker.LoginPhase == LinkLeaf.LinkLogin.Ready)
                            ServerCore.Linker.SendPacket(LinkLeaf.LeafOutbound.LeafNameChanged(ServerCore.Linker, current, this._name));
                    }
            }
        }

        public ushort Vroom
        {
            get { return this._vroom; }
            set
            {
                if (this.SocketConnected)
                    if (Events.VroomChanging(this, value))
                    {
                        if (!this.LoggedIn)
                            this._vroom = value;
                        else
                        {
                            if (this.Quarantined)
                                return;

                            this.LoggedIn = false;

                            if (!this.Cloaked)
                            {
                                LinkLeaf.LinkUser other = null;

                                if (ServerCore.Linker.Busy)
                                    foreach (LinkLeaf.Leaf leaf in ServerCore.Linker.Leaves)
                                    {
                                        other = leaf.Users.Find(x => x.Vroom == this.Vroom && x.name=%3D this.Name && !x.Link.Visible);

                                        if (other != null)
                                        {
                                            other.LinkCredentials.Visible = true;
                                            break;
                                        }
                                    }

                                UserPool.AUsers.ForEachWhere(x => x.SendPacket(other == null ? TCPOutbound.Part(x, this) : TCPOutbound.UpdateUserStatus(x, other)),
                                    x => x.LoggedIn && x.Vroom == this.Vroom && !x.Quarantined);

                                UserPool.WUsers.ForEachWhere(x => x.QueuePacket(other == null ? ib0t.WebOutbound.PartTo(x, this.Name) : ib0t.WebOutbound.UpdateTo(x, other.Name, other.Level)),
                                    x => x.LoggedIn && x.Vroom == this.Vroom && !x.Quarantined);
                            }

                            this._vroom = value;
                            Helpers.FakeRejoinSequence(this, false);

                            if (ServerCore.Linker.Busy && ServerCore.Linker.LoginPhase == LinkLeaf.LinkLogin.Ready)
                                ServerCore.Linker.SendPacket(LinkLeaf.LeafOutbound.LeafVroomChanged(ServerCore.Linker, this));
                        }

                        Events.VroomChanged(this);
                    }
            }
        }

        public ILevel Level
        {
            get { return this._level; }
            set
            {
                if (value != this._level)
                {
                    this._level = value;

                    if (this.LoggedIn && !this.Cloaked)
                    {
                        UserPool.AUsers.ForEachWhere(x => x.SendPacket(TCPOutbound.UpdateUserStatus(x, this)),
                            x => x.LoggedIn && x.Vroom == this.Vroom && !x.Quarantined);

                        UserPool.WUsers.ForEachWhere(x => x.QueuePacket(ib0t.WebOutbound.UpdateTo(x, this.Name, this._level)),
                            x => x.LoggedIn && x.Vroom == this.Vroom && !x.Quarantined);

                        if (ServerCore.Linker.Busy && ServerCore.Linker.LoginPhase == LinkLeaf.LinkLogin.Ready)
                            ServerCore.Linker.SendPacket(LinkLeaf.LeafOutbound.LeafUserUpdated(ServerCore.Linker, this));
                    }

                    this.SendPacket(TCPOutbound.OpChange(this));
                    Events.AdminLevelChanged(this);
                }
            }
        }

        public void Print(object text)
        {
            this.SendPacket(TCPOutbound.NoSuch(this, text.ToString()));
        }

        public void BinaryWrite(byte[] data)
        {
            this.SendPacket(data);
        }

        private void DnsReceived(IAsyncResult result)
        {
            if (this.SocketConnected)
                try
                {
                    IPHostEntry i = Dns.EndGetHostEntry(result);
                    this.DNS = Helpers.ObfuscateDns(i.HostName);
                }
                catch
                {
                    try
                    {
                        this.DNS = Helpers.ObfuscateDns(this.ExternalIP.ToString());
                    }
                    catch { }
                }
        }

        private byte[] rest_av = null;

        public byte[] Avatar
        {
            get { return this.avatar; }
            set
            {
                if (value == null)
                {
                    value = new byte[] { };

                    if (this.avatar != null)
                        if (this.avatar.Length >= 10)
                            this.rest_av = this.avatar;
                }

                if (value.Length < 10)
                {
                    this.avatar = new byte[] { };
                    this.AvatarReceived = false;

                    if (!this.Cloaked && !this.Quarantined)
                    {
                        UserPool.AUsers.ForEachWhere(x => x.SendPacket(TCPOutbound.AvatarCleared(x, this)),
                            x => x.LoggedIn && x.Vroom == this.Vroom && !x.Quarantined);

                        UserPool.WUsers.ForEachWhere(x => x.QueuePacket(ib0t.WebOutbound.AvatarClearTo(x, this.Name)),
                            x => x.LoggedIn && x.Vroom == this.Vroom && !x.Quarantined && x.Extended);

                        if (ServerCore.Linker.Busy && ServerCore.Linker.LoginPhase == LinkLeaf.LinkLogin.Ready)
                            ServerCore.Linker.SendPacket(LinkLeaf.LeafOutbound.LeafAvatar(ServerCore.Linker, this));
                    }
                }
                else
                {
                    this.avatar = value;

                    if (!this.Cloaked && !this.Quarantined)
                    {
                        UserPool.AUsers.ForEachWhere(x => x.SendPacket(TCPOutbound.Avatar(x, this)),
                            x => x.LoggedIn && x.Vroom == this.Vroom && !x.Quarantined);

                        UserPool.WUsers.ForEachWhere(x => x.QueuePacket(ib0t.WebOutbound.AvatarTo(x, this.Name, this.Avatar)),
                            x => x.LoggedIn && x.Vroom == this.Vroom && !x.Quarantined && x.Extended);

                        if (ServerCore.Linker.Busy && ServerCore.Linker.LoginPhase == LinkLeaf.LinkLogin.Ready)
                            ServerCore.Linker.SendPacket(LinkLeaf.LeafOutbound.LeafAvatar(ServerCore.Linker, this));
                    }
                }
            }
        }

        public String PersonalMessage
        {
            get { return this.personal_message; }
            set
            {
                this.personal_message = value == null ? String.Empty : value;

                if (!this.Cloaked && !this.Quarantined)
                {
                    UserPool.AUsers.ForEachWhere(x => x.SendPacket(TCPOutbound.PersonalMessage(x, this)),
                        x => x.LoggedIn && x.Vroom == this.Vroom && !x.Quarantined);

                    UserPool.WUsers.ForEachWhere(x => x.QueuePacket(ib0t.WebOutbound.PersMsgTo(x, this.Name, this.personal_message)),
                        x => x.LoggedIn && x.Vroom == this.Vroom && !x.Quarantined && x.Extended);

                    if (ServerCore.Linker.Busy && ServerCore.Linker.LoginPhase == LinkLeaf.LinkLogin.Ready)
                        ServerCore.Linker.SendPacket(LinkLeaf.LeafOutbound.LeafPersonalMessage(ServerCore.Linker, this));
                }
            }
        }

        public bool SocketConnected
        {
            get { return this.socket_health < 10; }
            set { this.socket_health = value ? 0 : 10; }
        }

        public void SendPacket(byte[] packet)
        {
            this.data_out.Enqueue(packet);
        }

        public void SendReceive()
        {
            while (this.data_out.Count > 0)
            {
                try
                {
                    byte[] packet;

                    if (this.data_out.TryPeek(out packet))
                    {
                        this.Sock.Send(packet);
                        Stats.DataSent += (ulong)packet.Length;

                        while (!this.data_out.TryDequeue(out packet))
                            continue;
                    }
                    else break;
                }
                catch { break; }
            }

            byte[] buffer = new byte[8192];
            int received = 0;
            SocketError e = SocketError.Success;

            try { received = this.Sock.Receive(buffer, 0, buffer.Length, SocketFlags.None, out e); }
            catch { }

            if (received == 0)
                this.socket_health = e == SocketError.WouldBlock ? 0 : (this.socket_health + 1);
            else
            {
                this.socket_health = 0;
                this.data_in.AddRange(buffer.Take(received));
                Stats.DataReceived += (ulong)received;
            }

            if (!this.LoggedIn)
                if (!this.IsHTML)
                    if (this.data_in.Count >= 3)
                    {
                        String test_str = Encoding.UTF8.GetString(this.data_in.ToArray()).ToUpper();
                        this.IsHTML = test_str.StartsWith("GET / ");
                       
                        if (!this.IsHTML)
                            this.IsWebWorker = test_str.StartsWith("GET");
                    }
        }

        public void EnforceRules(ulong time)
        {
            if ((!this.LoggedIn && time > (this.Time + 15000)) ||
                (this.LoggedIn && time > (this.Time + 240000)))
            {
                this.SocketConnected = false;
                ServerCore.Log("ping timeout or login timeout from " + this.ExternalIP + " id: " + this.ID);
            }
        }

        public void Disconnect()
        {
            this.Disconnect(false);
        }

        public void Disconnect(bool ghost)
        {
            while (this.data_out.Count > 0)
            {
                try
                {
                    byte[] packet;

                    if (this.data_out.TryPeek(out packet))
                    {
                        this.Sock.Send(packet);
                        Stats.DataSent += (ulong)packet.Length;

                        while (!this.data_out.TryDequeue(out packet))
                            continue;
                    }
                    else break;
                }
                catch { break; }
            }

            try { this.Sock.Disconnect(false); }
            catch { }
            try { this.Sock.Shutdown(SocketShutdown.Both); }
            catch { }
            try { this.Sock.Close(); }
            catch { }
            try { this.Sock.Dispose(); }
            catch { }

            this.SocketConnected = false;

            if (!ghost)
                this.SendDepart();
            else if (this.LoggedIn && !this.Quarantined)
            {
                this.LoggedIn = false;
                Events.Parting(this);

                if (ServerCore.Linker.Busy && ServerCore.Linker.LoginPhase == LinkLeaf.LinkLogin.Ready)
                    ServerCore.Linker.SendPacket(LinkLeaf.LeafOutbound.LeafPart(ServerCore.Linker, this));

                Events.Parted(this);
            }

            this.LoggedIn = false;
        }

        public void SendDepart()
        {
            if (this.LoggedIn && !this.Quarantined)
            {
                this.LoggedIn = false;
                Events.Parting(this);

                if (!this.Cloaked)
                {
                    LinkLeaf.LinkUser other = null;

                    if (ServerCore.Linker.Busy)
                        foreach (LinkLeaf.Leaf leaf in ServerCore.Linker.Leaves)
                        {
                            other = leaf.Users.Find(x => x.Vroom == this.Vroom && x.name=%3D this.Name && !x.Link.Visible);

                            if (other != null)
                            {
                                other.LinkCredentials.Visible = true;
                                break;
                            }
                        }

                    UserPool.AUsers.ForEachWhere(x => x.SendPacket(other == null ? TCPOutbound.Part(x, this) : TCPOutbound.UpdateUserStatus(x, other)),
                        x => x.LoggedIn && x.Vroom == this.Vroom && !x.Quarantined);

                    UserPool.WUsers.ForEachWhere(x => x.QueuePacket(other == null ? ib0t.WebOutbound.PartTo(x, this.Name) : ib0t.WebOutbound.UpdateTo(x, other.Name, other.Level)),
                        x => x.LoggedIn && x.Vroom == this.Vroom && !x.Quarantined);

                    if (ServerCore.Linker.Busy && ServerCore.Linker.LoginPhase == LinkLeaf.LinkLogin.Ready)
                        ServerCore.Linker.SendPacket(LinkLeaf.LeafOutbound.LeafPart(ServerCore.Linker, this));
                }

                Events.Parted(this);
            }
        }

        public TCPPacket NextReceivedPacket
        {
            get
            {
                if (this.data_in.Count < 3)
                    return null;

                ushort size = BitConverter.ToUInt16(this.data_in.ToArray(), 0);
                byte id = this.data_in[2];

                if (this.data_in.Count >= (size + 3))
                {
                    TCPPacket packet = new TCPPacket();
                    packet.Msg = (TCPMsg)id;
                    packet.Packet = new TCPPacketReader(this.data_in.GetRange(3, size).ToArray());
                    this.data_in.RemoveRange(0, (size + 3));
                    return packet;
                }

                return null;
            }
        }

        public void InsertUnzippedData(byte[] data)
        {
            this.data_in.InsertRange(0, data);
        }

        public byte[] ReceiveDump
        {
            get { return this.data_in.ToArray(); }
        }

       
    }
}


Bueno esta es mi primera pregunta:
Que significano los corchetes en la línea 82?
private byte[] avatar = new byte[] { };

Melse refiero a estos corchetes { }

Gracias y saludos
#17
Hola a todos,
bueno como siempre antes de la pregunta les mostrare la tarea y el codigo:

Tarea:
Desarrollar una clase para la administración de un árbol binario ordenado.

Codigo:
Código: php

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

namespace ArbolBinarioOrdenado1
{
    public class ArbolBinarioOrdenado {
        class Nodo
        {
            public int info;
            public Nodo izq, der;
        }
        Nodo raiz;

        public ArbolBinarioOrdenado()
        {
            raiz=null;
        }
     
        public void Insertar (int info)
        {
            Nodo nuevo;
            nuevo = new Nodo ();
            nuevo.info = info;
            nuevo.izq = null;
            nuevo.der = null;
            if (raiz == null)
                raiz = nuevo;
            else
            {
                Nodo anterior = null, reco;
                reco = raiz;
                while (reco != null)
                {
                    anterior = reco;
                    if (info < reco.info)
                        reco = reco.izq;
                    else
                        reco = reco.der;
                }
                if (info < anterior.info)
                    anterior.izq = nuevo;
                else
                    anterior.der = nuevo;
            }
        }


        private void ImprimirPre (Nodo reco)
        {
            if (reco != null)
            {
                Console.Write(reco.info + " ");
                ImprimirPre (reco.izq);
                ImprimirPre (reco.der);
            }
        }

        public void ImprimirPre ()
        {
            ImprimirPre (raiz);
            Console.WriteLine();
        }

        private void ImprimirEntre (Nodo reco)
        {
            if (reco != null)
            {   
                ImprimirEntre (reco.izq);
                Console.Write(reco.info + " ");
                ImprimirEntre (reco.der);
            }
        }

        public void ImprimirEntre ()
        {
            ImprimirEntre (raiz);
            Console.WriteLine();
        }


        private void ImprimirPost (Nodo reco)
        {
            if (reco != null)
            {
                ImprimirPost (reco.izq);
                ImprimirPost (reco.der);
                Console.Write(reco.info + " ");
            }
        }


        public void ImprimirPost ()
        {
            ImprimirPost (raiz);
            Console.WriteLine();
        }

        static void Main(string[] args)
        {
            ArbolBinarioOrdenado abo = new ArbolBinarioOrdenado ();
            abo.Insertar (100);
            abo.Insertar (50);
            abo.Insertar (25);
            abo.Insertar (75);
            abo.Insertar (150);
            Console.WriteLine ("Impresion preorden: ");
            abo.ImprimirPre ();
            Console.WriteLine ("Impresion entreorden: ");
            abo.ImprimirEntre ();
            Console.WriteLine ("Impresion postorden: ");
            abo.ImprimirPost ();
            Console.ReadKey();
        }
    }
}


La pregunta es esta:
Si la consola me devuelve esto:


Entonces no coincide con esta regla:

Árbol binario

Preorden: (raíz, izquierdo, derecho). Para recorrer un árbol binario no vacío en preorden, hay que realizar las siguientes operaciones recursivamente en cada nodo, comenzando con el nodo de raíz:
Visite la raíz
Atraviese el sub-árbol izquierdo
Atraviese el sub-árbol derecho

Inorden: (izquierdo, raíz, derecho). Para recorrer un árbol binario no vacío en inorden (simétrico), hay que realizar las siguientes operaciones recursivamente en cada nodo:
Atraviese el sub-árbol izquierdo
Visite la raíz
Atraviese el sub-árbol derecho

Postorden: (izquierdo, derecho, raíz). Para recorrer un árbol binario no vacío en postorden, hay que realizar las siguientes operaciones recursivamente en cada nodo:
Atraviese el sub-árbol izquierdo
Atraviese el sub-árbol derecho
Visite la raíz

En el postorden me devuelve esto:
25 75 50 150 100

Pero primero tengo que atravesar el sub-árbol izquierdo como en el primer paso del entreorden, a saber, 25 50 (los primeros dos nodos)


Gracias y saludos
#18
Hola,

antes de preguntar, les mostrare el codigo:

archivo: Form1.Designer.cs
Código: php

namespace Laberinto
{
    partial class Form1
    {
        ///

        /// Variable del diseñador requerida.
        ///

        private System.ComponentModel.IContainer components = null;

        ///

        /// Limpiar los recursos que se estén utilizando.
        ///

        /// true si los recursos administrados se deben eliminar; false en caso contrario, false.
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Código generado por el Diseñador de Windows Forms

        ///

        /// Método necesario para admitir el Diseñador. No se puede modificar
        /// el contenido del método con el editor de código.
        ///

        private void InitializeComponent()
        {
            this.button1 = new System.Windows.Forms.Button();
            this.button2 = new System.Windows.Forms.Button();
            this.SuspendLayout();
            //
            // button1
            //
            this.button1.Location = new System.Drawing.Point(11, 15);
            this.button1.name=%26quot%3Bbutton1%26quot%3B%3B
            this.button1.Size = new System.Drawing.Size(75, 23);
            this.button1.TabIndex = 0;
            this.button1.Text = "Verificar";
            this.button1.UseVisualStyleBackColor = true;
            this.button1.Click += new System.EventHandler(this.button1_Click);
            //
            // button2
            //
            this.button2.Location = new System.Drawing.Point(93, 15);
            this.button2.name=%26quot%3Bbutton2%26quot%3B%3B
            this.button2.Size = new System.Drawing.Size(124, 23);
            this.button2.TabIndex = 1;
            this.button2.Text = "Otro laberinto";
            this.button2.UseVisualStyleBackColor = true;
            this.button2.Click += new System.EventHandler(this.button2_Click);
            //
            // Form1
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(345, 428);
            this.Controls.Add(this.button2);
            this.Controls.Add(this.button1);
            this.name=%26quot%3BForm1%26quot%3B%3B
            this.Text = "Form1";
            this.Load += new System.EventHandler(this.Form1_Load);
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.Button button1;
        private System.Windows.Forms.Button button2;
    }
}


archivo: Form1.cs

Código: php

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Laberinto
{
    public partial class Form1 : Form
    {
        private Label[,] mat;
        private bool salida;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            int x = 10;
            int y = 50;
            mat=new Label[10,10];
            for (int fil = 0; fil < mat.GetLength(0); fil++)
            {
                for (int col = 0; col < mat.GetLength(1); col++)
                {
                    mat[fil, col] = new Label();
                    mat[fil, col].Location = new Point(x, y);
                    mat[fil, col].Size = new Size(30, 30);
                    Controls.Add(mat[fil, col]);
                    x = x + 32;
                }
                y = y + 32;
                x = 10;
            }
            Crear();
        }

        private void Crear()
        {
            Text = "";
            button1.Enabled = true;
            Random ale=new Random();
            for(int f = 0; f < 10; f++)
            {
                for(int c = 0; c < 10; c++)
                {
                    mat[f, c].BackColor = Color.Azure;
                    int a=ale.Next(0,4);
                    if (a==0)
                        mat[f,c].Text="1";
                    else
                        mat[f,c].Text="0";; 
                }
            }
            mat[9,9].Text="s";
            mat[0,0].Text="0";   
        }

        private void Recorrer(int fil, int col)
        {
            if (fil >= 0 && fil < 10 && col >= 0 && col < 10 && salida == false)
            {
                if (mat[fil,col].Text=="s")
                    salida = true;
                else
                    if (mat[fil,col].Text=="0")
                    {
                        mat[fil,col].Text="9";
                        mat[fil,col].BackColor=Color.Red;
                        Recorrer(fil, col + 1);
                        Recorrer(fil + 1, col);
                        Recorrer(fil - 1, col);
                        Recorrer(fil, col - 1);
                    }
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            button1.Enabled = false;
            salida = false;
            Recorrer(0, 0);
            if (salida == true)
                Text = "Tiene salida";
            else
                Text = "No tiene salida";
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Crear();
        }       
    }
}


Mi pregunta esta en el archivo Form1.cs. En el evento Load:

Código: php

private void Form1_Load(object sender, EventArgs e)
        {
            int x = 10;
            int y = 50;
            mat=new Label[10,10];
            for (int fil = 0; fil < mat.GetLength(0); fil++)
            {
                for (int col = 0; col < mat.GetLength(1); col++)
                {
                    mat[fil, col] = new Label();
                    mat[fil, col].Location = new Point(x, y);
                    mat[fil, col].Size = new Size(30, 30);
                    Controls.Add(mat[fil, col]);
                    x = x + 32;
                }
                y = y + 32;
                x = 10;
            }
            Crear();
        }


Mi pregunta es: que hace esta linea?:
mat[fil, col].Location = new Point(x, y);

Que significa Location?

Gracias y saludos
#19
Hola,

queria implementar un método recursivo que imprima en forma descendente de 5 a 1 de uno en uno. Me encontre en internet con esto:


Código: csharp
public class Recursividad {

    void imprimir(int x) {
        if (x>0) {
            System.out.println(x);
            imprimir(x-1);
        }   
    }
   
    public static void main(String[] ar) {
        Recursividad re=new Recursividad();
        re.imprimir(5);
    }


Pero tengo un problema:
Que significa System.out.println?

Gracias y saludos
#20
Hola,
queria saber la ip de una sala de chat de ares que se esconde detras de un proxy.
Es de ayuda el monitor de recursos?

Gracias y saludos
#21
Hola,
para mi duda este es el codigo del programa:


Código: csharp
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ListaGenerica1
{
    class ListaGenerica
    {
        class Nodo
        {
            public int info;
            public Nodo sig;
        }

        private Nodo raiz;

        public ListaGenerica()
        {
            raiz = null;
        }

        void Insertar(int pos, int x)
        {
            if (pos <= Cantidad() + 1)
            {
                Nodo nuevo = new Nodo();
                nuevo.info = x;
                if (pos == 1)
                {
                    nuevo.sig = raiz;
                    raiz = nuevo;
                }
                else
                    if (pos == Cantidad() + 1)
                    {
                        Nodo reco = raiz;
                        while (reco.sig != null)
                        {
                            reco = reco.sig;
                        }
                        reco.sig = nuevo;
                        nuevo.sig = null;
                    }
                    else
                    {
                        Nodo reco = raiz;
                        for (int f = 1; f <= pos - 2; f++)
                            reco = reco.sig;
                        Nodo siguiente = reco.sig;
                        reco.sig = nuevo;
                        nuevo.sig = siguiente;
                    }
            }
        }

        public int Extraer(int pos)
        {
            if (pos <= Cantidad())
            {
                int informacion;
                if (pos == 1)
                {
                    informacion = raiz.info;
                    raiz = raiz.sig;
                }
                else
                {
                    Nodo reco;
                    reco = raiz;
                    for (int f = 1; f <= pos - 2; f++)
                        reco = reco.sig;
                    Nodo prox = reco.sig;
                    reco.sig = prox.sig;
                    informacion = prox.info;
                }
                return informacion;
            }
            else
                return int.MaxValue;
        }

        public void Borrar(int pos)
        {
            if (pos <= Cantidad())
            {
                if (pos == 1)
                {
                    raiz = raiz.sig;
                }
                else
                {
                    Nodo reco;
                    reco = raiz;
                    for (int f = 1; f <= pos - 2; f++)
                        reco = reco.sig;
                    Nodo prox = reco.sig;
                    reco.sig = prox.sig;
                }
            }
        }

        public void Intercambiar(int pos1, int pos2)
        {
            if (pos1 <= Cantidad() && pos2 <= Cantidad())
            {
                Nodo reco1 = raiz;
                for (int f = 1; f < pos1; f++)
                    reco1 = reco1.sig;
                Nodo reco2 = raiz;
                for (int f = 1; f < pos2; f++)
                    reco2 = reco2.sig;
                int aux = reco1.info;
                reco1.info = reco2.info;
                reco2.info = aux;
            }
        }

        public int Mayor()
        {
            if (!Vacia())
            {
                int may = raiz.info;
                Nodo reco = raiz.sig;
                while (reco != null)
                {
                    if (reco.info > may)
                        may = reco.info;
                    reco = reco.sig;
                }
                return may;
            }
            else
                return int.MaxValue;
        }

        public int PosMayor()
        {
            if (!Vacia())
            {
                int may = raiz.info;
                int x = 1;
                int pos = x;
                Nodo reco = raiz.sig;
                while (reco != null)
                {
                    if (reco.info > may)
                    {
                        may = reco.info;
                        pos = x;
                    }
                    reco = reco.sig;
                    x++;
                }
                return pos;
            }
            else
                return int.MaxValue;
        }

        public int Cantidad()
        {
            int cant = 0;
            Nodo reco = raiz;
            while (reco != null)
            {
                reco = reco.sig;
                cant++;
            }
            return cant;
        }

        public bool Ordenada()
        {
            if (Cantidad() > 1)
            {
                Nodo reco1 = raiz;
                Nodo reco2 = raiz.sig;
                while (reco2 != null)
                {
                    if (reco2.info < reco1.info)
                    {
                        return false;
                    }
                    reco2 = reco2.sig;
                    reco1 = reco1.sig;
                }
            }
            return true;
        }

        public bool Existe(int x)
        {
            Nodo reco = raiz;
            while (reco != null)
            {
                if (reco.info == x)
                    return true;
                reco = reco.sig;
            }
            return false;
        }

        public bool Vacia()
        {
            if (raiz == null)
                return true;
            else
                return false;
        }

        public void Imprimir()
        {
            Nodo reco = raiz;
            while (reco != null) {
                Console.Write (reco.info + "-");
                reco = reco.sig;
            }
            Console.WriteLine();
        }

        static void Main(string[] args)
        {
            ListaGenerica lg=new ListaGenerica();
            lg.Insertar (1, 10);
            lg.Insertar (2, 20);
            lg.Insertar (3, 30);
            lg.Insertar (2, 15);
            lg.Insertar (1, 115);
            lg.Imprimir ();
            Console.WriteLine ("Luego de Borrar el primero");
            lg.Borrar (1);
            lg.Imprimir ();
            Console.WriteLine ("Luego de Extraer el segundo");
            lg.Extraer (2);
            lg.Imprimir ();
            Console.WriteLine ("Luego de Intercambiar el primero con el tercero");
            lg.Intercambiar (1, 3);
            lg.Imprimir ();
            if (lg.Existe(10))
                Console.WriteLine("Se encuentra el 20 en la lista");
            else
                Console.WriteLine("No se encuentra el 20 en la lista");
            Console.WriteLine("La posición del mayor es:"+lg.PosMayor());
            if (lg.Ordenada())
                Console.WriteLine("La lista está ordenada de menor a mayor");
            else
                Console.WriteLine("La lista no está ordenada de menor a mayor");
            Console.ReadKey();
        }
    }
}


Bueno, al principio raiz apunta a null.
raiz = null;

Luego viene un nodo con la informacion 10.
lg.Insertar (1, 10);

Luego, el campo sig de este nodo apunta a raiz, que contiene null.
nuevo.sig = raiz;

Luego viene otro nodo con la informacion 20.
lg.Insertar (2, 20);

Luego el campo sig del nodo con la informacion 10 apunta al nodo con la informacion 20? Y con eso el nodo con la informacion 10 deja de apuntar al nodo raiz=null?
Nodo reco = raiz;
                        while (reco.sig != null)
                        {
                            reco = reco.sig;
                        }
                        reco.sig = nuevo;
                        nuevo.sig = null;

Que cosa entendi mal?

Gracias y saludos
#22
Hola,
en realidad es un simple duda. Pero creo importante mostrarlo todo.

Queria desarrollar un programa para la simulación de un cajero automático.
Se cuenta con la siguiente información:
- Llegan clientes a la puerta del cajero cada 2 ó 3 minutos.
- Cada cliente tarda entre 2 y 4 minutos para ser atendido.

Queria que el programa obtenga las siguientes informaciónes:
1 - Cantidad de clientes que se atienden en 10 horas.
2 - Cantidad de clientes que hay en cola después de 10 horas.
3 - Hora de llegada del primer cliente que no es atendido luego de 10 horas (es decir la persona que está primera en la cola cuando se cumplen 10 horas)

Para eso hice en Form1.cs [Diseno] lo siguiente:


Y en Form1.cs puse lo siguiente:
Código: php

using ListaTipoCola2;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Random ale = new Random();
            int estado = 0;
            int llegada = 2 + ale.Next(0, 2);
            int salida = -1;
            int cantAtendidas = 0;
            Cola cola = new Cola();
            for (int minuto = 0; minuto < 600; minuto++)
            {
                if (llegada == minuto)
                {
                    if (estado == 0)
                    {
                        estado = 1;
                        salida = minuto + 2 + ale.Next(0, 3);
                    }
                    else
                    {
                        cola.Insertar(minuto);
                    }
                    llegada = minuto + 2 + ale.Next(0, 2);
                }
                if (salida == minuto)
                {
                    estado = 0;
                    cantAtendidas++;
                    if (!cola.Vacia())
                    {
                        cola.Extraer();
                        estado = 1;
                        salida = minuto + 2 + ale.Next(0, 3);
                    }
                }
            }
            label1.Text = "Atendidos: " + cantAtendidas.ToString();
            label2.Text = "En cola: " + cola.Cantidad().ToString();
            label3.Text = "Minuto llegada: " + cola.Extraer().ToString();
        }
    }
}


Y en Cola.cs lo siguiente:
Código: php

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

namespace ListaTipoCola2
{
    class Cola
    {
        class Nodo
        {
            public int info;
            public Nodo sig;
        }

        private Nodo raiz, fondo;

        public Cola()
        {
            raiz = null;
            fondo = null;
        }

        public bool Vacia()
        {
            if (raiz == null)
                return true;
            else
                return false;
        }

        public void Insertar(int info)
        {
            Nodo nuevo;
            nuevo = new Nodo();
            nuevo.info = info;
            nuevo.sig = null;
            if (Vacia())
            {
                raiz = nuevo;
                fondo = nuevo;
            }
            else
            {
                fondo.sig = nuevo;
                fondo = nuevo;
            }
        }

        public int Extraer()
        {
            if (!Vacia())
            {
                int informacion = raiz.info;
                if (raiz == fondo)
                {
                    raiz = null;
                    fondo = null;
                }
                else
                {
                    raiz = raiz.sig;
                }
                return informacion;
            }
            else
                return int.MaxValue;
        }

        public int Cantidad()
        {
            int cant = 0;
            Nodo reco = raiz;
            while (reco != null)
            {
                cant++;
                reco = reco.sig;
            }
            return cant;
        }
    }
}


Puesto que copie Form1.cs tengo una duda aqui:
Código: php

Random ale=new Random();
            int estado = 0;
            int llegada = 2 + ale.Next(0,2);
            int salida = -1;
            int cantAtendidas = 0;
            Cola cola = new Cola();


Que significa esta linea?
Random ale=new Random();

Hace mucho aprendi lo que es Random pero me olvide. Y en internet no lo explican tan bien como lo hace grep. Razon por la que no lo entiendo.

Gracias y saludos
#23
Hola,
en Form1.cs [Diseno]* hice esto:




en Pila.cs puse este codigo:

Código: php

Pila pila1;
            pila1 = new Pila();
            string cadena = textBox1.Text;
            for (int f = 0; f < cadena.Length; f++)
            {
                if (cadena.ElementAt(f) == '(' || cadena.ElementAt(f) == '[' || cadena.ElementAt(f) == '{')
                {
                    pila1.Insertar(cadena.ElementAt(f));
                }
                else
                {
                    if (cadena.ElementAt(f) == ')')
                    {
                        if (pila1.Extraer() != '(')
                        {
                            Text = "Incorrecta";
                            return;
                        }
                    }
                    else
                    {
                        if (cadena.ElementAt(f) == ']')
                        {
                            if (pila1.Extraer() != '[')
                            {
                                Text = "Incorrecta";
                                return;
                            }
                        }
                        else
                        {
                            if (cadena.ElementAt(f) == '}')
                            {
                                if (pila1.Extraer() != '{')
                                {
                                    Text = "Incorrecta";
                                    return;
                                }
                            }
                        }
                    }
                }
            }
            if (pila1.Vacia())
            {
                Text = "Correcta";
            }
            else
            {
                Text = "Incorrecta";
            }
        }
    }
}


en Form1.cs* puse este codigo:

Código: php

using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Pila pila1;
            pila1 = new Pila();
            string cadena = textBox1.Text;
            for (int f = 0; f < cadena.Length; f++)
            {
                if (cadena.ElementAt(f) == '(' || cadena.ElementAt(f) == '[' || cadena.ElementAt(f) == '{')
                {
                    pila1.Insertar(cadena.ElementAt(f));
                }
                else
                {
                    if (cadena.ElementAt(f) == ')')
                    {
                        if (pila1.Extraer() != '(')
                        {
                            Text = "Incorrecta";
                            return;
                        }
                    }
                    else
                    {
                        if (cadena.ElementAt(f) == ']')
                        {
                            if (pila1.Extraer() != '[')
                            {
                                Text = "Incorrecta";
                                return;
                            }
                        }
                        else
                        {
                            if (cadena.ElementAt(f) == '}')
                            {
                                if (pila1.Extraer() != '{')
                                {
                                    Text = "Incorrecta";
                                    return;
                                }
                            }
                        }
                    }
                }
            }
            if (pila1.Vacia())
            {
                Text = "Correcta";
            }
            else
            {
                Text = "Incorrecta";
            }
        }
    }
}


Pero cuando quiero iniciar el programa me aparecen los siguientes errores:




Luego me voy a Form1.cs* en la linea 22 y adonde dice Pila le doy a mostrar posibles correcciones.
Luego le doy click a Formul.Pila.

Y me aparece este error que no lo puedo sacar:




Alguien me puedo ayudar?

Gracias y saludos
#24
Hola,
desde hoy, cuando abro Visual Studio me aparece esto (nunca se me aparecio):



Pero en realidad deberia empezar asi:



Alguien sabe como ponerlo otra vez normal?

Gracias y saludos
#25
Hola,

antes que nada:

Código: csharp
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ListasTipoPila1
{
    class Pila
    {
        class Nodo
        {
            public int info;
            public Nodo sig;
        }

        private Nodo raiz;

        public Pila()
        {
            raiz = null;
        }

        public void Insertar(int x)
        {
            Nodo nuevo;
            nuevo = new Nodo();
            nuevo.info = x;
            if (raiz == null)
            {
                nuevo.sig = null;
                raiz = nuevo;
            }
            else
            {
                nuevo.sig = raiz;
                raiz = nuevo;
            }
        }

        public int Extraer()
        {
            if (raiz != null)
            {
                int informacion = raiz.info;
                raiz = raiz.sig;
                return informacion;
            }
            else
            {
                return int.MaxValue;
            }
        }

        public void Imprimir()
        {
            Nodo reco=raiz;
            Console.WriteLine("Listado de todos los elementos de la pila.");
            while (reco!=null)
            {
                Console.Write(reco.info+"-");
                reco=reco.sig;
            }
            Console.WriteLine();
        }

        static void Main(string[] args)
        {
            Pila pila1=new Pila();
            pila1.Insertar(10);
            pila1.Insertar(40);
            pila1.Insertar(3);
            pila1.Imprimir();
            Console.WriteLine("Extraemos de la pila:"+pila1.Extraer());
            pila1.Imprimir();
            Console.ReadKey();
        }
    }
}

Ahora bien, la duda seria esta:

En el metodo Insertar se encuentra este pedazo:

else
            {
                nuevo.sig = raiz;
                raiz = nuevo;
            }


Porque, si la lista esta vacia, apunta sig hacia raiz? Para que el nodo no se extienda infinitamente?

Gracias y saludos