<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="http://phylevn.mexrom.net/gadgets/Blog/templates/atom.xsl"?><feed xmlns="http://www.w3.org/2005/Atom">
<title>Phylevn Internet Home</title>
<link rel="alternate" type="text/html" href="http://phylevn.mexrom.net" title="Phylevn Internet Home" />
	<author>
		<name>Filein Rommel Leon</name>
		<uri>http://phylevn.mexrom.net</uri>
	</author>
<subtitle>Solo Se Puede Ser Libre Cuándo No Se Tiene Nada Que Perder</subtitle>
<id>http://phylevn.mexrom.net</id>
<generator>JAWS 0.7.0</generator>
<rights>2007, Filein Rommel Leon</rights>
<updated>2008-12-28T17:22:14-06:00</updated>
<entry>
	<title><![CDATA[ X10 Protocolo para implementacion de Casas Inteligentes ]]></title>
	<link rel="alternate" type="text/html" href="index.php/blog/show/204.html" title="X10 Protocolo para implementacion de Casas Inteligentes" />
	<author>
		<name>Filein Rommel Leon</name>
		<uri>http://phylevn.mexrom.net</uri>
	</author>
	<id>http://blog/204</id>
	<updated>2008-12-28T17:22:14-06:00</updated>
	<published>2008-12-28T17:22:14-06:00</published>
	<summary><![CDATA[ 	<p>Investigando acerca de como implementar e integrar la tecnologia domótica en un proyecto personal me metí a buscar información sobre protocolos para control de dispositivos caseros desde Linux, para ello he encontrado los protocolos X10, KNX/EIB, entre otros, de los cuáles X10 me pareció muy interesante aparte que es un estándar de fácil implementación y que tiene soporte en Linux a traves de diversos proyectos.</p>
	<p>X10 es un protocolo que permite enviar y recibir señales a traves de las líneas eléctricas, de tal forma que existen "appliances" de diversas marcas que usan el protocolo X10 para recibir y enviar señalizaciones con lo que es posible enviar desde una PC una señal de apagado, encendido usando el protocolo X10 a traves de un convertidor de señal que convierte la información enviada a señales electricas que pasan por la red eléctrica hasta llegar al destino especificado para prender un aparato, apagarlo, aumentar su velocidad ó brillo.</p>
	<p>Los appliances es posible configurarles un ID que se basa en un identificador de casa y un identificador adicional de 5 bits con los cuáles es posible identificarlos dentro de una red X10 casera, así es posible enlazarlos y desde un convertidor Serial-PLC es posible enviar diversas señalizaciones, de tal forma que es posible enviar el encendido y/o apagado de un dispositivos específico en cierto tiempo.</p>
	<p>Lo interesante de esta tecnología es que con los convertidores de PC a PLC(Power Line Communication) es posible hacer infinidad de aplicaciones, una de ellas es que se pueden hacer interfaces usando AGIs para conectar Asterisk a un convertidor con lo cuál con una llamada poder encender  o apagar dispositivos tales como alarmas, videocamaras, etc.</p>
	<p>La tecnología X10 para muchos no es tan eficiente, ya que es suceptible a interfencias y a variaciones de voltajes y para ello los detractores de esta tecnología recomiendan hacer uso de del protocolo KNX el cuál no solo permite hacer señalizaciones por PLC si no también por TCP/IP y RF lo cuál resulta mucho más interesante.</p>
 ]]></summary>
	<content><![CDATA[ 	<p>Investigando acerca de como implementar e integrar la tecnologia domótica en un proyecto personal me metí a buscar información sobre protocolos para control de dispositivos caseros desde Linux, para ello he encontrado los protocolos X10, KNX/EIB, entre otros, de los cuáles X10 me pareció muy interesante aparte que es un estándar de fácil implementación y que tiene soporte en Linux a traves de diversos proyectos.</p>
	<p>X10 es un protocolo que permite enviar y recibir señales a traves de las líneas eléctricas, de tal forma que existen "appliances" de diversas marcas que usan el protocolo X10 para recibir y enviar señalizaciones con lo que es posible enviar desde una PC una señal de apagado, encendido usando el protocolo X10 a traves de un convertidor de señal que convierte la información enviada a señales electricas que pasan por la red eléctrica hasta llegar al destino especificado para prender un aparato, apagarlo, aumentar su velocidad ó brillo.</p>
	<p>Los appliances es posible configurarles un ID que se basa en un identificador de casa y un identificador adicional de 5 bits con los cuáles es posible identificarlos dentro de una red X10 casera, así es posible enlazarlos y desde un convertidor Serial-PLC es posible enviar diversas señalizaciones, de tal forma que es posible enviar el encendido y/o apagado de un dispositivos específico en cierto tiempo.</p>
	<p>Lo interesante de esta tecnología es que con los convertidores de PC a PLC(Power Line Communication) es posible hacer infinidad de aplicaciones, una de ellas es que se pueden hacer interfaces usando AGIs para conectar Asterisk a un convertidor con lo cuál con una llamada poder encender  o apagar dispositivos tales como alarmas, videocamaras, etc.</p>
	<p>La tecnología X10 para muchos no es tan eficiente, ya que es suceptible a interfencias y a variaciones de voltajes y para ello los detractores de esta tecnología recomiendan hacer uso de del protocolo KNX el cuál no solo permite hacer señalizaciones por PLC si no también por TCP/IP y RF lo cuál resulta mucho más interesante.</p>
 ]]></content>
		<category scheme="index.php/blog/category/1.html" term="2" label="Tecnología"/>
		<category scheme="index.php/blog/category/1.html" term="8" label="Voz Sobre IP"/>
		<category scheme="index.php/blog/category/1.html" term="11" label="Trabajo y Proyectos"/>
</entry>
<entry>
	<title><![CDATA[ DimDim Plataforma de desarrollo de conferencias web y comunicaciones Open Source ]]></title>
	<link rel="alternate" type="text/html" href="index.php/blog/show/203.html" title="DimDim Plataforma de desarrollo de conferencias web y comunicaciones Open Source" />
	<author>
		<name>Filein Rommel Leon</name>
		<uri>http://phylevn.mexrom.net</uri>
	</author>
	<id>http://blog/203</id>
	<updated>2008-12-25T00:31:12-06:00</updated>
	<published>2008-12-24T13:51:03-06:00</published>
	<summary><![CDATA[ 	<p>Buscando información de <a href=http://osflash.org/red5>RED5</a> para implementar un servidor de VideoConferencias y otras cosas más para un curso en línea  que voy a dar en próximos días, me encontré entre la lista de quienes han implementado RED5 a <a href=http://www.dimdim.com>DimDim</a>, el cuál  es una plataforma para comunicaciones y videoconferencias vía web.</p>
	<p><a href=http://www.dimdim.com>DimDim</a> está basado en RED5 el cuál es un proyecto OpenSource, DimDIm aunque tiene una versión libre disponible para la comunidad, también tiene otra 2 versiones de cobro las cuáles tienen ventajas adicionales. </p>
	<p>Entre las características de DimDim es el soporte de comunicaciones multimedia en tiempo real lo que implica transmitir video, audio, texto, imágenes y documentos entre múltiples usuarios a traves de una aplicación flash que comúnmente puede llamarse chat, otra de las cosas interesantes de DimDim es la capacidad de proyectar documentos de <a href=http://www.openoffice.org>OpenOffice</a> y <a href=http://microsoft.com>Office</a>en la página web(chat) para que pueda ser vista por todos los asistentes, pero lo que sin duda es de llamar la atención es el WhiteBoard que trae incluído con lo que la interacción entre los usuarios del chat es simplemente toda una experiencia, pues a traves del WhiteBoard se pueden plasmar ideas y soluciones que muchas veces es complicado explicar o entender con textos o palabras, esto cuándo se está en un videoconferencia.</p>
	<p>Puede echársele un ojo a un video que muestra lo que es DimDim en su versión OpenSource, la cuál sin duda es una aplicación muy práctica para lo que es el eLearning y otras cosas más.</p>
	<p><a href=http://www.dimdim.com/opensource/dimdim_open_source_community_edition.html>http://www.dimdim.com/opensource/dimdim_open_source_community_edition.html</a></p>
 ]]></summary>
	<content><![CDATA[ 	<p>Buscando información de <a href=http://osflash.org/red5>RED5</a> para implementar un servidor de VideoConferencias y otras cosas más para un curso en línea  que voy a dar en próximos días, me encontré entre la lista de quienes han implementado RED5 a <a href=http://www.dimdim.com>DimDim</a>, el cuál  es una plataforma para comunicaciones y videoconferencias vía web.</p>
	<p><a href=http://www.dimdim.com>DimDim</a> está basado en RED5 el cuál es un proyecto OpenSource, DimDIm aunque tiene una versión libre disponible para la comunidad, también tiene otra 2 versiones de cobro las cuáles tienen ventajas adicionales. </p>
	<p>Entre las características de DimDim es el soporte de comunicaciones multimedia en tiempo real lo que implica transmitir video, audio, texto, imágenes y documentos entre múltiples usuarios a traves de una aplicación flash que comúnmente puede llamarse chat, otra de las cosas interesantes de DimDim es la capacidad de proyectar documentos de <a href=http://www.openoffice.org>OpenOffice</a> y <a href=http://microsoft.com>Office</a>en la página web(chat) para que pueda ser vista por todos los asistentes, pero lo que sin duda es de llamar la atención es el WhiteBoard que trae incluído con lo que la interacción entre los usuarios del chat es simplemente toda una experiencia, pues a traves del WhiteBoard se pueden plasmar ideas y soluciones que muchas veces es complicado explicar o entender con textos o palabras, esto cuándo se está en un videoconferencia.</p>
	<p>Puede echársele un ojo a un video que muestra lo que es DimDim en su versión OpenSource, la cuál sin duda es una aplicación muy práctica para lo que es el eLearning y otras cosas más.</p>
	<p><a href=http://www.dimdim.com/opensource/dimdim_open_source_community_edition.html>http://www.dimdim.com/opensource/dimdim_open_source_community_edition.html</a></p>
 ]]></content>
		<category scheme="index.php/blog/category/1.html" term="2" label="Tecnología"/>
		<category scheme="index.php/blog/category/1.html" term="3" label="Programacion"/>
		<category scheme="index.php/blog/category/1.html" term="8" label="Voz Sobre IP"/>
		<category scheme="index.php/blog/category/1.html" term="11" label="Trabajo y Proyectos"/>
		<category scheme="index.php/blog/category/1.html" term="18" label="Software Libre"/>
</entry>
<entry>
	<title><![CDATA[ Como configurar servidor Punto Multipunto con OpenVPN y cliente en Windows ó Linux. ]]></title>
	<link rel="alternate" type="text/html" href="index.php/blog/show/201.html" title="Como configurar servidor Punto Multipunto con OpenVPN y cliente en Windows ó Linux." />
	<author>
		<name>Filein Rommel Leon</name>
		<uri>http://phylevn.mexrom.net</uri>
	</author>
	<id>http://blog/201</id>
	<updated>2008-12-21T00:16:26-06:00</updated>
	<published>2008-12-20T23:56:46-06:00</published>
	<summary><![CDATA[ 	<p><a href=http://www.openvpn.org>OpenVPN</a> es un software basado en la filosofía de software libre, que permite crear conexiones VPN entre equipos Linux, Windows, MacOSX, *BSD, *nix y Dispositivos móviles como Windows Mobile a traves de redes inseguras como internet o redes inalámbricas.</p>
	<p>OpenVPN puede funcionar de varias maneras una de ellas de punto a punto, punto a multipunto y en modo bridge.</p>
	<li>Punto a Punto: solo realiza una conexión segura entre 2 equipos, esta conexión puede usarse para compartir archivos entre 2 equipos en internet.
	<li>Punto a multipunto: Permite conectar a diversos dispositivos a un servidor OpenVPN el cuál permitirá redigir las peticiones remotas a una red interna a traves de una red como internet. El uso de este modo es factible para dar acceso a aplicaciones dentro de una red local a equipos que se encuentran en alguna parte de internet.
	<li>Modo Bridge: OpenVPN permite crear conexiones entre 2 redes remotas, de tal forma que OpenVPN funciona como gateway de un punto y otro para poder unificar las redes, esto es muy factible cuándo se tienen  oficinas remotas y se desea unificarlas, una de sus ventajas se da para las aplicaciones de Voz sobre IP, Bases de Datos, etc.
	<p>Nuestro caso: Punto a Mutipunto.</p>
	<p>Este tipo de modo de OpenVPN en mi caso es el que más uso, ya que me dedico a desarrollar aplicaciones para dispositivos móviles los cuáles se conectan a  internet a traves de conexiones GPRS(Movistar y Telcel en México), de tal forma que les instalo un cliente OpenVPN a los móviles y de esta forma se conectan a un servidor OpenVPN, esto para poder acceder a las bases de datos, a los web services, servidores FTP, etc., de una forma muy segura sin comprometer la información en redes públicas.</p>
	<p>Para comenzar con OpenVPN necesitamos descargar el instalador para Windows de OpenVPN, el cuál puede obtenerse de la siguiente URL:</p>
	<p><a href=http://openvpn.net/release/openvpn-2.0.9-install.exe> http://openvpn.net/release/openvpn-2.0.9-install.exe</a></p>
	<p>Esto probablemente nos instale el software de OpenVPN en el siguiente directorio:
C:\Archivos de Programa\OpenVPN</p>
	<p>Abrir la consola de Windows
Inicio->Ejecutar->CMD</p>
	<p>Ya en la consola de Windows ir al directorio easy-rsa de OpenVPN
cd C:\Archivos de Programa\OpenVPN\easy-rsa\</p>
	<p>Lo primero que se hará es crear un Certificado de Autoridad (CA)
Ejecutar :
#Inicia el proceso
<br>init-config</p>
	<p>#Aqui pedirá valores como Pais, Estado, Ciudad, Organización, Depto,  Nombre del Servidor y Correo, todos estos valores se repetirán a excepción del nombre del host que en la parte de configuración de las llaves del cliente en la parte última.
<br>vars</p>
	<p><br>clean-all
<br>build-ca</p>
	<p>#Al finalizar esta parte se crearán varios archivos en directorio 
<br>C:\Archivos de Programa\OpenVPN\easy-rsa\keys</p>
	<p>#Copiar el archivo keys\ca.crt al directorio <br>C:\Archivos de Programa\OpenVPN\config
<br>copy keys\ca.crt ..\config\</p>
	<p>Con lo anterior habremos creado el Certificado de Autoridad.</p>
	<p>El siguiente paso es crear la llave privada y certificado del servidor.</p>
	<p>Ejecutar en el directorio easy-rsa el siguiente comando
<br>vars
<br>build-key-server phylevn.mexrom.net</p>
	<p>#dónde phylevn.mexrom.net es el nombre del servidor dónde se está instalando OpenVPN.</p>
	<p>#Aquí de igual pedirá datos, los cuáles deben ser los mismos introducidos anteriormente, también pedirá un password, este mismo password debe ser usado cuándo se creen las llave de los clientes.</p>
	<p>#Luego ejecutar el siguiente comando</p>
	<p>build-dh</p>
	<p>#Con esto se habrán creado otros archivos en el directorio keys.</p>
	<p>#Copiar los siguientes archivos del directorio easy-rsa\keys a ..config\</p>
	<p><br>C:\Program Files\OpenVPN\easy-rsa> copy keys\phylevn.mexrom.net.crt ..\config\
<br>C:\Program Files\OpenVPN\easy-rsa> copy keys\phylevn.mexrom.net.key ..\config\
<br>C:\Program Files\OpenVPN\easy-rsa> copy keys\dh1024.pem ..\config\</p>
	<p>#Ahora hay que configurar el servidor para luego iniciarlo.</p>
	<p>#Dentro del archivo de configuración de OpenVPN
<br>C:\Program Files\OpenVPN\config</p>
	<p>#Crear un archivo llamado server.ovpn y dentro de ese archivo introducir lo siguiente</p>
	<p>port 1194
proto udp
dev tun
ca   "C:\Archivos de programa\OpenVPN\config\ca.crt"
cert "C:\Archivos de programa\OpenVPN\config\phylevn.mexrom.net.crt"
key  "C:\Archivos de programa\OpenVPN\config\phylevn.mexrom.net.key"  # Este archivo debe mantenerse en secreto 
dh    "C:\Archivos de programa\OpenVPN\config\dh1024.pem"
server 192.168.20.0 255.255.255.0 #Segmento de red que tomarán los clientes remotos
ifconfig-pool-persist ipp.txt
push "dhcp-option DNS 208.67.222.222"
push "dhcp-option WINS 192.168.20.1"
<img src="http://phylevn.mexrom.net/plugins/Emoticons/images/tongue.png" border="0" alt="tongue.png " width="16" height="16" />ush "route-gateway 192.168.20.1"
client-to-client
push "route 192.168.1.0 255.255.255.0" #Segmento de la red local interna
duplicate-cn    #Con esta opción no es necesario crear una llave por cada cliente
comp-lzo   #Comprime los datos envíados y recibidos
max-clients 60
persist-key
persist-tun
verb 3
status openvpn-status.log
keepalive 10 120
suppress-timestamps
route-delay 10 10</p>
	<p>#Ya con la configuración realizada solo basta darle click con el botón derecho del mouse al archivo server.ovpn y seleccionar la opción de Start with OpenVPN.</p>
	<p>#Pero antes de lo anterior hay que editar el registro de windows en la siguiente llave y reiniciar Windows.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters</p>
	<p>#Y en la opción de IPEnableRouter configurarlo a 1, esto para que se le permita a OpenVPN hacer el ruteo del segmento de la red privada a la red local interna.</p>
	<p>#Ahora si iniciar el servidor de OpenVPN</p>
	<p>#Si todo salió bien se abrirá una ventana de comandos y al final indicará 
<br>Initialization Sequence completed</p>
	<p>#Con esto ya tenemos el servidor de OpenVPN echado andara, ahora falta crear las llaves de los clientes, para esto realizar lo siguiente</p>
	<p>#En la consola de comandos ir a :
<br>C:\Archivos de programa\OpenVPN\easy-rsa</p>
	<p>#Introducir los siguientes comandos
<br>vars
<br>build-key phylevn</p>
	<p>#dónde cliente es el nombre del cliente remoto, debe cambiar por cada cliente remoto configurado en caso de que se creen múltiples llaves.</p>
	<p>#Al momento de ejecutar build-key hay que repetir la información anteriormente capturada a excepción del nombre del host que debe ser el nombre del equipo cliente, también en password debe ponerse el password que se dió al crear la llave privada y certificado del servidor de OpenVPN.</p>
	<p>#En seguida hay que crear los archivos al directorio config del servidor OpenVPN
<br>copy keys\phylevn.crt ..\config
<br>copy keys\phylevn.key ..\config</p>
	<p>#Y también estos archivo hay que pasarlos a la máquina remota, solo hay que tener un modo seguro para envío de estas llaves a las máquinas remotas, los arhivos que debe tener la máquina remota deben ser los siguientes</p>
	<p><br>ca.crt
<br>phylevn.crt
<br>phylevn.key</p>
	<p>Dónde phylevn es el nombre de la llave para el host especificado, en caso de que se permita la duplicación de llaves, no importaría el nombre del archivo cliente que se pase en caso de que se tengan varios.</p>
	<p>#Ahora en las máquinas clientes también hay que tener instalado el software OpenVPN</p>
	<p>#Y se debe crear un archivo de configuracion llamado cliente.ovpn en el directorio config de OpenVPN</p>
	<p><br>C:\Archivos de programa\OpenVPN\config\</p>
	<p>#El archivo cliente.ovpn debe contener lo siguiente:</p>
	<p>client
proto udp
dev tun
remote  201.123.42.174 1194 #Dirección IP Pública del servidor OpenVPN
resolv-retry infinite
nobind
persist-key
persist-tun
ca    "C:\Archivos de programa\OpenVPN\config\ca.crt"
cert  "C:\Archivos de programa\OpenVPN\config\phylevn.crt"
key   "C:\Archivos de programa\OpenVPN\config\phylevn.key"
comp-lzo
verb 3</p>
	<p>#Ya que esté guardado el archivo, solo basta presionar el botón derecho del mouse y presionar Start With OpenVPN, con esto el cliente se intentará validar con el servidor remoto, si todo salió bien, entonces el cliente tendra una nueva interfaz de red y le será asignada una IP en el segmento 192.168.20.x, con esto ya podrá hacer ping al servidor remoto, de igual forma a las IPs del segmento de la red local interna dónde se encuentra el servidor de OpenVPN.</p>
	<p>#Con Linux son los mismos pasos, a excepto de las rutas, pero el proceso es el mismo, solo se excluye la parte del registro de windows y se activa el IP Forwarding.</p>
 ]]></summary>
	<content><![CDATA[ 	<p><a href=http://www.openvpn.org>OpenVPN</a> es un software basado en la filosofía de software libre, que permite crear conexiones VPN entre equipos Linux, Windows, MacOSX, *BSD, *nix y Dispositivos móviles como Windows Mobile a traves de redes inseguras como internet o redes inalámbricas.</p>
	<p>OpenVPN puede funcionar de varias maneras una de ellas de punto a punto, punto a multipunto y en modo bridge.</p>
	<li>Punto a Punto: solo realiza una conexión segura entre 2 equipos, esta conexión puede usarse para compartir archivos entre 2 equipos en internet.
	<li>Punto a multipunto: Permite conectar a diversos dispositivos a un servidor OpenVPN el cuál permitirá redigir las peticiones remotas a una red interna a traves de una red como internet. El uso de este modo es factible para dar acceso a aplicaciones dentro de una red local a equipos que se encuentran en alguna parte de internet.
	<li>Modo Bridge: OpenVPN permite crear conexiones entre 2 redes remotas, de tal forma que OpenVPN funciona como gateway de un punto y otro para poder unificar las redes, esto es muy factible cuándo se tienen  oficinas remotas y se desea unificarlas, una de sus ventajas se da para las aplicaciones de Voz sobre IP, Bases de Datos, etc.
	<p>Nuestro caso: Punto a Mutipunto.</p>
	<p>Este tipo de modo de OpenVPN en mi caso es el que más uso, ya que me dedico a desarrollar aplicaciones para dispositivos móviles los cuáles se conectan a  internet a traves de conexiones GPRS(Movistar y Telcel en México), de tal forma que les instalo un cliente OpenVPN a los móviles y de esta forma se conectan a un servidor OpenVPN, esto para poder acceder a las bases de datos, a los web services, servidores FTP, etc., de una forma muy segura sin comprometer la información en redes públicas.</p>
	<p>Para comenzar con OpenVPN necesitamos descargar el instalador para Windows de OpenVPN, el cuál puede obtenerse de la siguiente URL:</p>
	<p><a href=http://openvpn.net/release/openvpn-2.0.9-install.exe> http://openvpn.net/release/openvpn-2.0.9-install.exe</a></p>
	<p>Esto probablemente nos instale el software de OpenVPN en el siguiente directorio:
C:\Archivos de Programa\OpenVPN</p>
	<p>Abrir la consola de Windows
Inicio->Ejecutar->CMD</p>
	<p>Ya en la consola de Windows ir al directorio easy-rsa de OpenVPN
cd C:\Archivos de Programa\OpenVPN\easy-rsa\</p>
	<p>Lo primero que se hará es crear un Certificado de Autoridad (CA)
Ejecutar :
#Inicia el proceso
<br>init-config</p>
	<p>#Aqui pedirá valores como Pais, Estado, Ciudad, Organización, Depto,  Nombre del Servidor y Correo, todos estos valores se repetirán a excepción del nombre del host que en la parte de configuración de las llaves del cliente en la parte última.
<br>vars</p>
	<p><br>clean-all
<br>build-ca</p>
	<p>#Al finalizar esta parte se crearán varios archivos en directorio 
<br>C:\Archivos de Programa\OpenVPN\easy-rsa\keys</p>
	<p>#Copiar el archivo keys\ca.crt al directorio <br>C:\Archivos de Programa\OpenVPN\config
<br>copy keys\ca.crt ..\config\</p>
	<p>Con lo anterior habremos creado el Certificado de Autoridad.</p>
	<p>El siguiente paso es crear la llave privada y certificado del servidor.</p>
	<p>Ejecutar en el directorio easy-rsa el siguiente comando
<br>vars
<br>build-key-server phylevn.mexrom.net</p>
	<p>#dónde phylevn.mexrom.net es el nombre del servidor dónde se está instalando OpenVPN.</p>
	<p>#Aquí de igual pedirá datos, los cuáles deben ser los mismos introducidos anteriormente, también pedirá un password, este mismo password debe ser usado cuándo se creen las llave de los clientes.</p>
	<p>#Luego ejecutar el siguiente comando</p>
	<p>build-dh</p>
	<p>#Con esto se habrán creado otros archivos en el directorio keys.</p>
	<p>#Copiar los siguientes archivos del directorio easy-rsa\keys a ..config\</p>
	<p><br>C:\Program Files\OpenVPN\easy-rsa> copy keys\phylevn.mexrom.net.crt ..\config\
<br>C:\Program Files\OpenVPN\easy-rsa> copy keys\phylevn.mexrom.net.key ..\config\
<br>C:\Program Files\OpenVPN\easy-rsa> copy keys\dh1024.pem ..\config\</p>
	<p>#Ahora hay que configurar el servidor para luego iniciarlo.</p>
	<p>#Dentro del archivo de configuración de OpenVPN
<br>C:\Program Files\OpenVPN\config</p>
	<p>#Crear un archivo llamado server.ovpn y dentro de ese archivo introducir lo siguiente</p>
	<p>port 1194
proto udp
dev tun
ca   "C:\Archivos de programa\OpenVPN\config\ca.crt"
cert "C:\Archivos de programa\OpenVPN\config\phylevn.mexrom.net.crt"
key  "C:\Archivos de programa\OpenVPN\config\phylevn.mexrom.net.key"  # Este archivo debe mantenerse en secreto 
dh    "C:\Archivos de programa\OpenVPN\config\dh1024.pem"
server 192.168.20.0 255.255.255.0 #Segmento de red que tomarán los clientes remotos
ifconfig-pool-persist ipp.txt
push "dhcp-option DNS 208.67.222.222"
push "dhcp-option WINS 192.168.20.1"
<img src="http://phylevn.mexrom.net/plugins/Emoticons/images/tongue.png" border="0" alt="tongue.png " width="16" height="16" />ush "route-gateway 192.168.20.1"
client-to-client
push "route 192.168.1.0 255.255.255.0" #Segmento de la red local interna
duplicate-cn    #Con esta opción no es necesario crear una llave por cada cliente
comp-lzo   #Comprime los datos envíados y recibidos
max-clients 60
persist-key
persist-tun
verb 3
status openvpn-status.log
keepalive 10 120
suppress-timestamps
route-delay 10 10</p>
	<p>#Ya con la configuración realizada solo basta darle click con el botón derecho del mouse al archivo server.ovpn y seleccionar la opción de Start with OpenVPN.</p>
	<p>#Pero antes de lo anterior hay que editar el registro de windows en la siguiente llave y reiniciar Windows.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters</p>
	<p>#Y en la opción de IPEnableRouter configurarlo a 1, esto para que se le permita a OpenVPN hacer el ruteo del segmento de la red privada a la red local interna.</p>
	<p>#Ahora si iniciar el servidor de OpenVPN</p>
	<p>#Si todo salió bien se abrirá una ventana de comandos y al final indicará 
<br>Initialization Sequence completed</p>
	<p>#Con esto ya tenemos el servidor de OpenVPN echado andara, ahora falta crear las llaves de los clientes, para esto realizar lo siguiente</p>
	<p>#En la consola de comandos ir a :
<br>C:\Archivos de programa\OpenVPN\easy-rsa</p>
	<p>#Introducir los siguientes comandos
<br>vars
<br>build-key phylevn</p>
	<p>#dónde cliente es el nombre del cliente remoto, debe cambiar por cada cliente remoto configurado en caso de que se creen múltiples llaves.</p>
	<p>#Al momento de ejecutar build-key hay que repetir la información anteriormente capturada a excepción del nombre del host que debe ser el nombre del equipo cliente, también en password debe ponerse el password que se dió al crear la llave privada y certificado del servidor de OpenVPN.</p>
	<p>#En seguida hay que crear los archivos al directorio config del servidor OpenVPN
<br>copy keys\phylevn.crt ..\config
<br>copy keys\phylevn.key ..\config</p>
	<p>#Y también estos archivo hay que pasarlos a la máquina remota, solo hay que tener un modo seguro para envío de estas llaves a las máquinas remotas, los arhivos que debe tener la máquina remota deben ser los siguientes</p>
	<p><br>ca.crt
<br>phylevn.crt
<br>phylevn.key</p>
	<p>Dónde phylevn es el nombre de la llave para el host especificado, en caso de que se permita la duplicación de llaves, no importaría el nombre del archivo cliente que se pase en caso de que se tengan varios.</p>
	<p>#Ahora en las máquinas clientes también hay que tener instalado el software OpenVPN</p>
	<p>#Y se debe crear un archivo de configuracion llamado cliente.ovpn en el directorio config de OpenVPN</p>
	<p><br>C:\Archivos de programa\OpenVPN\config\</p>
	<p>#El archivo cliente.ovpn debe contener lo siguiente:</p>
	<p>client
proto udp
dev tun
remote  201.123.42.174 1194 #Dirección IP Pública del servidor OpenVPN
resolv-retry infinite
nobind
persist-key
persist-tun
ca    "C:\Archivos de programa\OpenVPN\config\ca.crt"
cert  "C:\Archivos de programa\OpenVPN\config\phylevn.crt"
key   "C:\Archivos de programa\OpenVPN\config\phylevn.key"
comp-lzo
verb 3</p>
	<p>#Ya que esté guardado el archivo, solo basta presionar el botón derecho del mouse y presionar Start With OpenVPN, con esto el cliente se intentará validar con el servidor remoto, si todo salió bien, entonces el cliente tendra una nueva interfaz de red y le será asignada una IP en el segmento 192.168.20.x, con esto ya podrá hacer ping al servidor remoto, de igual forma a las IPs del segmento de la red local interna dónde se encuentra el servidor de OpenVPN.</p>
	<p>#Con Linux son los mismos pasos, a excepto de las rutas, pero el proceso es el mismo, solo se excluye la parte del registro de windows y se activa el IP Forwarding.</p>
 ]]></content>
		<category scheme="index.php/blog/category/1.html" term="2" label="Tecnología"/>
		<category scheme="index.php/blog/category/1.html" term="8" label="Voz Sobre IP"/>
		<category scheme="index.php/blog/category/1.html" term="11" label="Trabajo y Proyectos"/>
		<category scheme="index.php/blog/category/1.html" term="18" label="Software Libre"/>
</entry>
<entry>
	<title><![CDATA[ C/C++ y algunos problemas de bachillerato ]]></title>
	<link rel="alternate" type="text/html" href="index.php/blog/show/200.html" title="C/C++ y algunos problemas de bachillerato" />
	<author>
		<name>Filein Rommel Leon</name>
		<uri>http://phylevn.mexrom.net</uri>
	</author>
	<id>http://blog/200</id>
	<updated>2008-12-20T22:58:53-06:00</updated>
	<published>2008-12-20T22:58:53-06:00</published>
	<summary><![CDATA[ 	<p>Hace unos días me contacto un alumno de un COBAO(Colegio de Bachilleres) de Oaxaca, bachillerato dónde estudié hace algunos ayeres, pidiéndome que le asesorara con la resolución de algunos problemas de programación, por lo que le eché la mano ya que le habían pedido que resolviera algunos problemas simples de programación en C/C++ en su materia de informática y a la edad de 15 ó 16 años muy pocos son duchos con este lenguaje de programación - a menos que sean como <a href=http://xiam.menteslibres.org>Xiam</a> que es un chavo que desde corta edad se le ha dado la programada, linuxeada y demás-.</p>
	<p>Por lo que le pedí que me enviara las dudas para ayudarle a resolverlas, cabe mencionar que también tiene años que no programaba en C/C++ pues me he dedicado al desarrollo de aplicaciones web con PHP y AJAX, al igual que desarrollo de aplicaciones para móviles con .Net, por lo que me sirvió resolver estos problemas como recordatorio de C/C++.</p>
	<p>Los problemas son los siguientes:</p>
	<li>1.- Diseñar un programa que a partir de la fecha introducida por teclado con el formato día, mes, año se obtena el siguiente día considerando el año bisiesto.
<div class="code"><div class="c">
<span style="color: #339933;">#include &lt;stdio.h&gt;</span><br />
<span style="color: #339933;">#include &lt;stdlib.h&gt;</span><br />
<span style="color: #339933;">#include &lt;string.h&gt;</span><br />
<span style="color: #339933;">#include &lt;conio.h&gt;</span></p>
	<p><span style="color: #993333;">int</span> main<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> argc, <span style="color: #993333;">char</span> <strong>argv<span style="color: #66cc66;">&#41;</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; <span style="color: #993333;">char</span> *fecha;<br />
&#160; &#160; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>argc&gt;<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>&#160; &#160; &#160; &#160; <br />
&#160; &#160; &#160; &#160; fecha = malloc<span style="color: #66cc66;">&#40;</span>strlen<span style="color: #66cc66;">&#40;</span>argv<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; strcpy<span style="color: #66cc66;">&#40;</span>fecha, argv<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; <span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; <span style="color: #993333;">char</span> dato<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#93;</span>;<br />
&#160; &#160; &#160; &#160; &#160; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"fecha:"</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; scanf<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"%s"</span>, dato<span style="color: #66cc66;">&#41;</span>;</p>
	<p>&#160; &#160; &#160; &#160; &#160; fecha = malloc<span style="color: #66cc66;">&#40;</span>strlen<span style="color: #66cc66;">&#40;</span>dato<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; strcpy<span style="color: #66cc66;">&#40;</span>fecha, dato<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; <span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; validaFecha<span style="color: #66cc66;">&#40;</span>fecha<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; getch<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160;<span style="color: #66cc66;">&#125;</span></p>
	<p>
&#160;validaFecha<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">char</span> *fecha<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; <span style="color: #993333;">int</span> datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span>;<br />
&#160; &#160; &#160; &#160; <span style="color: #993333;">char</span> *ptr;<br />
&#160; &#160; &#160; &#160; <span style="color: #993333;">int</span> count = <span style="color: #cc66cc;">0</span>;<br />
&#160; &#160; &#160; &#160; <span style="color: #993333;">int</span> error = <span style="color: #cc66cc;">0</span>;<br />
&#160; &#160; &#160; &#160; ptr = strtok<span style="color: #66cc66;">&#40;</span>fecha,<span style="color: #ff0000;">"/"</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; <span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span>ptr != <span style="color: #000000; font-weight: bold;">NULL</span><span style="color: #66cc66;">&#41;</span><br />
&#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160;datos<span style="color: #66cc66;">&#91;</span>count++<span style="color: #66cc66;">&#93;</span> = atoi<span style="color: #66cc66;">&#40;</span>ptr<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160;ptr = strtok<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">NULL</span>, <span style="color: #ff0000;">"/"</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;">//Enero, Febrero, Marzo, Abril, Mayp, Junio, Julio, Agosto, Septiembre, Octubre, Noviembre, Diciembre</span><br />
&#160; &#160; &#160; &#160; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>count!=<span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Error en el formato de fecha...<span style="color: #000099; font-weight: bold;">\n</span>Help :<span style="color: #000099; font-weight: bold;">\n</span>Formato del programa<span style="color: #000099; font-weight: bold;">\n</span>nextDay dia/mes/anio<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>Ejemplo: nextDay 12/12/2009"</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; error++;<br />
&#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>&gt;<span style="color: #cc66cc;">0</span> &amp;&amp; datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>&lt;=<span style="color: #cc66cc;">12</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span> datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>==<span style="color: #cc66cc;">1</span> || datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>==<span style="color: #cc66cc;">3</span> || datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>==<span style="color: #cc66cc;">5</span> || datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>==<span style="color: #cc66cc;">7</span> || datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>==<span style="color: #cc66cc;">8</span> || datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>==<span style="color: #cc66cc;">10</span> || datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>==<span style="color: #cc66cc;">12</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>&gt;<span style="color: #cc66cc;">0</span> &amp;&amp; datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>&lt;=<span style="color: #cc66cc;">31</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>==<span style="color: #cc66cc;">31</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>=<span style="color: #cc66cc;">1</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>&lt;<span style="color: #cc66cc;">12</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>++;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;<span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>=<span style="color: #cc66cc;">1</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span>++;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;<span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;<span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>++;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;<span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Error en el dia de la fecha"</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; error++;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span> datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>&gt;<span style="color: #cc66cc;">0</span> &amp;&amp; <span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#40;</span>datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>&lt;=<span style="color: #cc66cc;">30</span> &amp;&amp; datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>!=<span style="color: #cc66cc;">2</span> <span style="color: #66cc66;">&#41;</span> || <span style="color: #66cc66;">&#40;</span> datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>&lt;=<span style="color: #cc66cc;">29</span> &amp;&amp; datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>==<span style="color: #cc66cc;">2</span> &amp;&amp; datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span>%<span style="color: #cc66cc;">4</span>==<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> || <span style="color: #66cc66;">&#40;</span>datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>&lt;=<span style="color: #cc66cc;">28</span> &amp;&amp; datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>==<span style="color: #cc66cc;">2</span> &amp;&amp; datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span>%<span style="color: #cc66cc;">4</span>!=<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>==<span style="color: #cc66cc;">30</span> &amp;&amp; datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>!=<span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>=<span style="color: #cc66cc;">1</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>++;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>==<span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#40;</span>datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>==<span style="color: #cc66cc;">28</span> &amp;&amp; datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span>%<span style="color: #cc66cc;">4</span>!=<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> || <span style="color: #66cc66;">&#40;</span>datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>==<span style="color: #cc66cc;">29</span> &amp;&amp; datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span>%<span style="color: #cc66cc;">4</span>==<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>=<span style="color: #cc66cc;">1</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>++;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>++;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>++;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">" Error en el formato de la fecha introducida "</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; error++;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"%d Error en el mes"</span>, datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;&#160; &#160; &#160; <br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;error++;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span>&#160; &#160; &#160; &#160; &#160; &#160; &#160; <br />
&#160; &#160; &#160; &#160; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>error==<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Dia siguiente: %d / %d / %d<span style="color: #000099; font-weight: bold;">\n</span>"</span>, datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>, datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>, datos<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; &#160; &#160; getch<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><br />
&#160;<span style="color: #66cc66;">&#125;</span></p>
	<p>&#160;</div></div>
	<li>2.- Obtener el número de combinaciones de m elementos tomado de n en n es: (m/n) = m!/(m!(m-n)!) que permita calcular el numero de combinaciones de (m/n)
<div class="code"><div class="c">
<span style="color: #339933;">#include &lt;stdio.h&gt;</span><br />
<span style="color: #339933;">#include &lt;stdlib.h&gt;</span><br />
<span style="color: #339933;">#include &lt;conio.h&gt;</span></p>
	<p>&#160;<span style="color: #993333;">int</span> factorial<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> numero<span style="color: #66cc66;">&#41;</span>;</p>
	<p><span style="color: #993333;">int</span> main<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> argc, <span style="color: #993333;">char</span> </strong>argv<span style="color: #66cc66;">&#41;</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; <span style="color: #993333;">int</span> m = <span style="color: #cc66cc;">0</span> ;<br />
&#160; &#160; <span style="color: #993333;">int</span> n = <span style="color: #cc66cc;">0</span>;<br />
&#160; &#160; <span style="color: #993333;">int</span> result = <span style="color: #cc66cc;">0</span>;<br />
&#160; &#160; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>argc&gt;<span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>&#160; &#160; &#160; &#160; <br />
&#160; &#160; &#160; &#160; m = atoi<span style="color: #66cc66;">&#40;</span>argv<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; n = atoi<span style="color: #66cc66;">&#40;</span>argv<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; <span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"m:"</span><span style="color: #66cc66;">&#41;</span>;scanf<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"%d"</span>, &amp;m<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"n:"</span><span style="color: #66cc66;">&#41;</span>;scanf<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"%d"</span>, &amp;n<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; <span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>n&lt;=m<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; result = factorial<span style="color: #66cc66;">&#40;</span>m<span style="color: #66cc66;">&#41;</span>/ <span style="color: #66cc66;">&#40;</span> factorial<span style="color: #66cc66;">&#40;</span>n<span style="color: #66cc66;">&#41;</span> * factorial<span style="color: #66cc66;">&#40;</span>m-n<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> ;<br />
&#160; &#160; &#160; &#160; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\n</span>Combinacion de %d elementos tomados de %d : %d"</span>, m, n, result<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; <span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Error el valor de [n] no puede ser mayor que el valor de [m]"</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; <span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; getch<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160;<span style="color: #66cc66;">&#125;</span><br />
&#160;<br />
&#160;<span style="color: #993333;">int</span> factorial<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> numero<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; <span style="color: #993333;">int</span> i = <span style="color: #cc66cc;">1</span>;<br />
&#160; &#160; &#160; &#160; <span style="color: #993333;">int</span> value = numero;<br />
&#160; &#160; &#160; &#160; <span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span>i=<span style="color: #cc66cc;">1</span> ;i&lt;numero; i++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160;value =&#160; value * i ; <br />
&#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span> <br />
&#160; &#160; &#160; &#160; <span style="color: #b1b100;">return</span> value;<br />
<span style="color: #66cc66;">&#125;</span></p>
	<p>
&#160;</div></div>
	<li>3.- Diseñar un programa que transforme un numero introducido en formato decimal y lo convierta en notación romana, el número debe ser positivo y no excederse de 3000.
<div class="code"><div class="c">
<span style="color: #339933;">#include &lt;stdio.h&gt;</span><br />
<span style="color: #339933;">#include &lt;stdlib.h&gt;</span><br />
<span style="color: #339933;">#include &lt;string.h&gt;</span><br />
<span style="color: #339933;">#include &lt;conio.h&gt;</span><br />
<span style="color: #993333;">void</span>&#160; &#160;romanos<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> numero <span style="color: #66cc66;">&#41;</span>;</p>
	<p><span style="color: #993333;">int</span> main<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> argc, <span style="color: #993333;">char</span> <strong>argv<span style="color: #66cc66;">&#41;</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; <span style="color: #993333;">int</span> numero = <span style="color: #cc66cc;">0</span> ;<br />
&#160; &#160; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>argc&gt;<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>&#160; &#160; &#160; &#160; <br />
&#160; &#160; &#160; &#160; numero = atoi<span style="color: #66cc66;">&#40;</span>argv<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; <span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Numero :"</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; scanf<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"%d"</span>, &amp;numero<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; <span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>numero&gt;=<span style="color: #cc66cc;">0</span> &amp;&amp; numero&lt;=<span style="color: #cc66cc;">3000</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160;romanos<span style="color: #66cc66;">&#40;</span>numero<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; <span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Error en el valor del numero introducido"</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; <span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; <br />
&#160;<span style="color: #66cc66;">&#125;</span></p>
	<p>
&#160; &#160; <span style="color: #993333;">void</span> romanos<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> numero&#160; <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160;<span style="color: #993333;">int</span> residuo&#160; = <span style="color: #cc66cc;">0</span>;<br />
&#160; &#160; &#160; &#160; &#160;<span style="color: #993333;">int</span> div = <span style="color: #cc66cc;">0</span>;<br />
&#160; &#160; &#160; &#160; &#160;<span style="color: #993333;">char</span> *a = <span style="color: #ff0000;">""</span>;<br />
&#160; &#160; &#160; &#160; &#160;<span style="color: #993333;">char</span> *b = <span style="color: #ff0000;">""</span>;<br />
&#160; &#160; &#160; &#160; &#160;<span style="color: #993333;">char</span> *c = <span style="color: #ff0000;">""</span>;<br />
&#160; &#160; &#160; &#160; &#160;<br />
&#160; &#160; &#160; &#160; &#160;<span style="color: #993333;">int</span> i = <span style="color: #cc66cc;">0</span>;<br />
&#160; &#160; &#160; &#160; &#160;<span style="color: #993333;">int</span> value = <span style="color: #cc66cc;">1000</span>;</p>
	<p>&#160; &#160; &#160; &#160; &#160;<span style="color: #993333;">char</span> *romano;<br />
&#160; &#160; &#160; &#160; &#160;romano = <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">char</span> *<span style="color: #66cc66;">&#41;</span>malloc<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">sizeof</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">char</span><span style="color: #66cc66;">&#41;</span>*<span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160;strcpy<span style="color: #66cc66;">&#40;</span>romano, <span style="color: #ff0000;">""</span><span style="color: #66cc66;">&#41;</span>;</p>
	<p>&#160; &#160; &#160; &#160; &#160;<span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span>numero&gt;<span style="color: #cc66cc;">0</span> &amp;&amp; value&gt;<span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160;residuo = numero % value;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160;<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>residuo&lt;numero<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; div = <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>numero-residuo<span style="color: #66cc66;">&#41;</span>/value<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">switch</span><span style="color: #66cc66;">&#40;</span>value<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">1000</span>:<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;a = <span style="color: #ff0000;">"M"</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;b = <span style="color: #ff0000;">"/V"</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;c = <span style="color: #ff0000;">"/X"</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;<span style="color: #000000; font-weight: bold;">break</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">100</span>:<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;a = <span style="color: #ff0000;">"C"</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;b = <span style="color: #ff0000;">"D"</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;c= <span style="color: #ff0000;">"M"</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;<span style="color: #000000; font-weight: bold;">break</span>;&#160; &#160; &#160; &#160; &#160; &#160; &#160; <br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">10</span>:<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;a = <span style="color: #ff0000;">"X"</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;b = <span style="color: #ff0000;">"L"</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;c = <span style="color: #ff0000;">"C"</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;<span style="color: #000000; font-weight: bold;">break</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">1</span>:<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;a = <span style="color: #ff0000;">"I"</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;b = <span style="color: #ff0000;">"V"</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;c = <span style="color: #ff0000;">"X"</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;<span style="color: #000000; font-weight: bold;">break</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>div==<span style="color: #cc66cc;">9</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;strcat<span style="color: #66cc66;">&#40;</span>romano, a<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;strcat<span style="color: #66cc66;">&#40;</span>romano, c<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>div==<span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; strcat<span style="color: #66cc66;">&#40;</span>romano, a<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;strcat<span style="color: #66cc66;">&#40;</span>romano, b<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>div&lt;<span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span>i=<span style="color: #cc66cc;">1</span>;i&lt;=div;i++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; strcat<span style="color: #66cc66;">&#40;</span>romano, a<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; strcat<span style="color: #66cc66;">&#40;</span>romano, b<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span>i=<span style="color: #cc66cc;">1</span>;i&lt;=<span style="color: #66cc66;">&#40;</span>div-<span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#41;</span>;i++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; strcat<span style="color: #66cc66;">&#40;</span>romano, a<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><span style="color: #808080; font-style: italic;">//fin del si no es menor que 5</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160;<span style="color: #66cc66;">&#125;</span><span style="color: #808080; font-style: italic;">//fin de si residuo menor que numero</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160;numero = residuo;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160;value = value/<span style="color: #cc66cc;">10</span>;<br />
&#160; &#160; &#160; &#160; &#160;<span style="color: #66cc66;">&#125;</span><span style="color: #808080; font-style: italic;">//fin del while</span><br />
&#160; &#160; &#160; &#160; &#160;<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\n</span>Numero Romano: %s<span style="color: #000099; font-weight: bold;">\n</span>"</span>, romano<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160;getch<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160;<br />
&#160; &#160; <span style="color: #66cc66;">&#125;</span><span style="color: #808080; font-style: italic;">//fin de la funcion</span></p>
	<p>&#160;</div></div>
	<li>4.- Escribir un procedimiento recursivo que escriba un numero en base 10 a otro número en base entre 2 y 9.
<div class="code"><div class="c">
<span style="color: #339933;">#include &lt;stdio.h&gt;</span><br />
<span style="color: #339933;">#include &lt;stdlib.h&gt;</span><br />
<span style="color: #339933;">#include &lt;string.h&gt;</span><br />
<span style="color: #339933;">#include &lt;conio.h&gt;</span><br />
<span style="color: #993333;">void</span>&#160; &#160;getBase<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> decimal, <span style="color: #993333;">int</span> base <span style="color: #66cc66;">&#41;</span>;</p>
	<p><span style="color: #993333;">int</span> main<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> argc, <span style="color: #993333;">char</span> </strong>argv<span style="color: #66cc66;">&#41;</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; <span style="color: #993333;">int</span> decimal = <span style="color: #cc66cc;">0</span> ;<br />
&#160; &#160; <span style="color: #993333;">int</span> base = <span style="color: #cc66cc;">0</span>;<br />
&#160; &#160; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>argc&gt;<span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>&#160; &#160; &#160; &#160; <br />
&#160; &#160; &#160; &#160; decimal = atoi<span style="color: #66cc66;">&#40;</span>argv<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; base = atoi<span style="color: #66cc66;">&#40;</span>argv<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; <span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"decimal:"</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; scanf<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"%d"</span>, &amp;decimal<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; <br />
&#160; &#160; &#160; &#160; &#160; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"base:"</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; scanf<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"%d"</span>, &amp;base<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; <span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>base&gt;=<span style="color: #cc66cc;">2</span> &amp;&amp; base &lt;=<span style="color: #cc66cc;">9</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160;getBase<span style="color: #66cc66;">&#40;</span>decimal,base<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; <span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"La base debe estar entre 2 y 9"</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; <span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; <br />
&#160;<span style="color: #66cc66;">&#125;</span></p>
	<p>
<span style="color: #993333;">void</span>&#160; getBase<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> decimal, <span style="color: #993333;">int</span> base <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160;<span style="color: #808080; font-style: italic;">//printf(&quot;%d::%d&quot;, decimal, base);</span><br />
&#160; &#160; &#160; &#160; &#160;<span style="color: #993333;">int</span> residuo = <span style="color: #cc66cc;">0</span>;<br />
&#160; &#160; &#160; &#160; &#160;<span style="color: #993333;">int</span> entero = decimal;<br />
&#160; &#160; &#160; &#160; &#160;<span style="color: #993333;">char</span> *result;<br />
&#160; &#160; &#160; &#160; &#160;<span style="color: #993333;">char</span> *temp;</p>
	<p>&#160; &#160; &#160; &#160; &#160;result = <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">char</span> *<span style="color: #66cc66;">&#41;</span>malloc<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">sizeof</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">char</span><span style="color: #66cc66;">&#41;</span>*<span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160;strcpy<span style="color: #66cc66;">&#40;</span>result, <span style="color: #ff0000;">""</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160;strcpy<span style="color: #66cc66;">&#40;</span>temp, <span style="color: #ff0000;">""</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160;<br />
&#160; &#160; &#160; &#160; &#160;<span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span>decimal&gt;=base<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160;residuo = decimal % base; <br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160;itoa<span style="color: #66cc66;">&#40;</span>residuo, temp, <span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160;strcat<span style="color: #66cc66;">&#40;</span>result, temp<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160;decimal = <span style="color: #66cc66;">&#40;</span>decimal-residuo<span style="color: #66cc66;">&#41;</span> / base;<br />
&#160; &#160; &#160; &#160; &#160;<span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; &#160; &#160; &#160;itoa<span style="color: #66cc66;">&#40;</span>decimal, temp, <span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160;strcat<span style="color: #66cc66;">&#40;</span>result, temp<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160;result&#160; = strrev<span style="color: #66cc66;">&#40;</span>result<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160;<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"El numero decimal %d en base %d es %s"</span>,entero, base, result <span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160;getch<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; <span style="color: #66cc66;">&#125;</span></p>
	<p>&#160;</div></div>
	<li>5.- Procedimiento recursivo que permita invertir una cadena.
<div class="code"><div class="c">
<span style="color: #339933;">#include &lt;stdio.h&gt;</span><br />
<span style="color: #339933;">#include &lt;stdlib.h&gt;</span><br />
<span style="color: #339933;">#include &lt;string.h&gt;</span><br />
<span style="color: #339933;">#include &lt;conio.h&gt;</span><br />
<span style="color: #993333;">void</span>&#160; &#160;invertir<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">char</span> *cadena<span style="color: #66cc66;">&#41;</span>;</p>
	<p><span style="color: #993333;">int</span> main<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> argc, <span style="color: #993333;">char</span> <strong>argv<span style="color: #66cc66;">&#41;</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; <span style="color: #993333;">int</span> decimal = <span style="color: #cc66cc;">0</span> ;<br />
&#160; &#160; <span style="color: #993333;">int</span> base = <span style="color: #cc66cc;">0</span>;<br />
&#160; &#160; <span style="color: #993333;">char</span> *cadena;</p>
	<p>&#160; &#160; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>argc&gt;<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>&#160; &#160; &#160; &#160; <br />
&#160; &#160; &#160; &#160; strcpy<span style="color: #66cc66;">&#40;</span>cadena, argv<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; <span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; strcpy<span style="color: #66cc66;">&#40;</span>cadena, <span style="color: #ff0000;">" "</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; <span style="color: #66cc66;">&#125;</span>&#160; &#160; <br />
&#160; &#160; <span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span>strlen<span style="color: #66cc66;">&#40;</span>cadena<span style="color: #66cc66;">&#41;</span>&gt;<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; invertir<span style="color: #66cc66;">&#40;</span>cadena<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\n</span>Cadena a Invertir[Enter para salir]: "</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; gets<span style="color: #66cc66;">&#40;</span>cadena<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; <span style="color: #66cc66;">&#125;</span><br />
&#160;<span style="color: #66cc66;">&#125;</span></p>
	<p>
&#160; <span style="color: #993333;">void</span>&#160; invertir<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">char</span> *cadena<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; <span style="color: #993333;">int</span> i = <span style="color: #cc66cc;">0</span>;<br />
&#160; &#160; &#160; &#160; <span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span>i=strlen<span style="color: #66cc66;">&#40;</span>cadena<span style="color: #66cc66;">&#41;</span>; i&gt;=<span style="color: #cc66cc;">0</span>; i--<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160;<span style="color: #808080; font-style: italic;">//result[j++] = cadena[i] ;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160;<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"%c"</span>, cadena<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span>&#160; &#160; &#160; &#160; <br />
&#160; <span style="color: #66cc66;">&#125;</span></p>
	<p>&#160;</div></div>
	<li>6.- Calcular la suma de todos los números en un vector de 100 elementos y obtener su media aritmética.
<div class="code"><div class="c">
<span style="color: #339933;">#include &lt;stdio.h&gt;</span><br />
<span style="color: #339933;">#include &lt;stdlib.h&gt;</span><br />
<span style="color: #339933;">#include &lt;string.h&gt;</span><br />
<span style="color: #339933;">#include &lt;conio.h&gt;</span><br />
<span style="color: #993333;">void</span>&#160; &#160;media<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> num<span style="color: #66cc66;">&#41;</span>;</p>
	<p><span style="color: #993333;">int</span> main<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> argc, <span style="color: #993333;">char</span> </strong>argv<span style="color: #66cc66;">&#41;</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; <span style="color: #993333;">int</span> vector = <span style="color: #cc66cc;">0</span> ;<br />
&#160; &#160; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>argc&gt;<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>&#160; &#160; &#160; &#160; <br />
&#160; &#160; &#160; &#160; vector = atoi<span style="color: #66cc66;">&#40;</span>argv<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; <span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; vector = <span style="color: #cc66cc;">100</span>;<br />
&#160; &#160; <span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; &#160;<span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span>vector&gt;<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; media<span style="color: #66cc66;">&#40;</span>vector<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\n</span>Tamañoi del vector [0 para salir]: "</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; scanf<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"%d"</span>, &amp;vector<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160;<span style="color: #66cc66;">&#125;</span><br />
&#160;<span style="color: #66cc66;">&#125;</span></p>
	<p>
<span style="color: #993333;">void</span>&#160; &#160;media<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> num<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160;<span style="color: #993333;">int</span> *values;<br />
&#160; &#160; &#160; &#160;<span style="color: #993333;">int</span> i = <span style="color: #cc66cc;">0</span>;<br />
&#160; &#160; &#160; &#160;values = <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> *<span style="color: #66cc66;">&#41;</span>malloc<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">sizeof</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span>*num<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160;<span style="color: #993333;">int</span> suma = <span style="color: #cc66cc;">0</span>;<br />
&#160; &#160; &#160; &#160;<span style="color: #993333;">float</span> media = <span style="color: #cc66cc;">0</span>;<br />
&#160; &#160; &#160; &#160;<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span>i=<span style="color: #cc66cc;">0</span>;i&lt;num;i++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160;values<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> = <span style="color: #66cc66;">&#40;</span>rand<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>%<span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span>;<span style="color: #808080; font-style: italic;">//numeros aleatorios entre 0 y 99</span><br />
&#160; &#160; &#160; &#160; &#160; &#160;suma = suma +values<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;<br />
&#160; &#160; &#160; &#160;<span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; &#160; &#160;<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\n</span>Vector: "</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160;<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span>i=<span style="color: #cc66cc;">0</span>; i&lt;num;i++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160;<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"%d, "</span>, values<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160;<span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; &#160; &#160;media = <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">float</span> <span style="color: #66cc66;">&#41;</span> suma / num;<br />
&#160; &#160; &#160; &#160;<br />
&#160; &#160; &#160; &#160;<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\n</span>Media :%10.5f"</span>, media<span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span></p>
	<p>&#160;</div></div>
<div class="code"><div class="c">
	<p>&#160;</div></div>
	<li>7.- Escribir un programa que permita sumar el numero de elementos positivos y de elementos negativos de una tabla T en n Filas y en m columnas.
<div class="code"><div class="c">
<span style="color: #339933;">#include &lt;stdio.h&gt;</span><br />
<span style="color: #339933;">#include &lt;stdlib.h&gt;</span><br />
<span style="color: #339933;">#include &lt;string.h&gt;</span><br />
<span style="color: #339933;">#include &lt;conio.h&gt;</span><br />
<span style="color: #993333;">void</span>&#160; &#160;tabla<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> m, <span style="color: #993333;">int</span> n <span style="color: #66cc66;">&#41;</span>;</p>
	<p><span style="color: #993333;">int</span> main<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> argc, <span style="color: #993333;">char</span> <strong>argv<span style="color: #66cc66;">&#41;</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; <span style="color: #993333;">int</span> m = <span style="color: #cc66cc;">0</span> ;<br />
&#160; &#160; <span style="color: #993333;">int</span> n = <span style="color: #cc66cc;">0</span>;<br />
&#160; &#160; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>argc&gt;<span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>&#160; &#160; &#160; &#160; <br />
&#160; &#160; &#160; &#160; m = atoi<span style="color: #66cc66;">&#40;</span>argv<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; n = atoi<span style="color: #66cc66;">&#40;</span>argv<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; <span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Filas(m):"</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; scanf<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"%d"</span>, &amp;m<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; <br />
&#160; &#160; &#160; &#160; &#160; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Columans(n):"</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; scanf<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"%d"</span>, &amp;n<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; <span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; &#160;tabla<span style="color: #66cc66;">&#40;</span>m,n<span style="color: #66cc66;">&#41;</span>;<br />
&#160;<span style="color: #66cc66;">&#125;</span></p>
	<p>
&#160;<span style="color: #993333;">void</span>&#160; tabla<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> m, <span style="color: #993333;">int</span> n <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160;<span style="color: #993333;">int</span> dato = <span style="color: #cc66cc;">0</span>;<br />
&#160; &#160; &#160; &#160; &#160;<span style="color: #993333;">int</span> pos = <span style="color: #cc66cc;">0</span>;<br />
&#160; &#160; &#160; &#160; &#160;<span style="color: #993333;">int</span> neg = <span style="color: #cc66cc;">0</span>;<br />
&#160; &#160; &#160; &#160; &#160;<span style="color: #993333;">int</span> i = <span style="color: #cc66cc;">0</span>;<br />
&#160; &#160; &#160; &#160; &#160;<span style="color: #993333;">int</span> j = <span style="color: #cc66cc;">0</span>;<br />
&#160; &#160; &#160; &#160; &#160;<span style="color: #993333;">int</span> *values = <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> *<span style="color: #66cc66;">&#41;</span>malloc<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">sizeof</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span>*m*n<span style="color: #66cc66;">&#41;</span>;</p>
	<p>&#160; &#160; &#160; &#160; &#160;<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>i =&#160; <span style="color: #cc66cc;">0</span>; i&lt;m; i++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160;<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>j=<span style="color: #cc66cc;">0</span>;j&lt;n;j++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\n</span>dato[%d,%d]: "</span>, i+<span style="color: #cc66cc;">1</span>, j+<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;scanf<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"%d"</span>, &amp;dato<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;values<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#40;</span>i*n<span style="color: #66cc66;">&#41;</span>+j<span style="color: #66cc66;">&#93;</span> = dato;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>dato&gt;=<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;pos++;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;<span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;neg++;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;<span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160;<span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; &#160; &#160; &#160;<span style="color: #66cc66;">&#125;</span></p>
	<p>&#160; &#160; &#160; &#160; &#160;<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\n</span>Matriz<span style="color: #000099; font-weight: bold;">\n</span>"</span><span style="color: #66cc66;">&#41;</span>;&#160; &#160; &#160; &#160; &#160;<br />
&#160; &#160; &#160; &#160; &#160;<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>i =&#160; <span style="color: #cc66cc;">0</span>; i&lt;m; i++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160;<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>j=<span style="color: #cc66cc;">0</span>;j&lt;n;j++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>&#160; &#160; &#160; &#160; &#160;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"%d, "</span>, values<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#40;</span>i*n<span style="color: #66cc66;">&#41;</span>+j<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160;<span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160;<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\n</span>"</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160;<span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; &#160; &#160; <br />
&#160; &#160; &#160; &#160; &#160;<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\n</span>Numeros positivos: %d<span style="color: #000099; font-weight: bold;">\n</span>Numeros negativos: %d"</span>, pos, neg<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160;getch<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; <span style="color: #66cc66;">&#125;</span></p>
	<p>&#160;</div></div>
	<li>8.- Suponiendo que existen N ciudades en la red ferroviaria de un pais y que sus nombres están almacenados en un vector llamado Ciudad. Diseñar un programa que lea los nombres de las Ciudades y muestre con que ciudades esté enlazada.
<div class="code"><div class="c">
<span style="color: #339933;">#include &lt;stdio.h&gt;</span><br />
<span style="color: #339933;">#include &lt;stdlib.h&gt;</span><br />
<span style="color: #339933;">#include &lt;conio.h&gt;</span><br />
<span style="color: #339933;">#include &lt;string.h&gt;</span></p>
	<p>&#160;<span style="color: #993333;">int</span> ferroviaria<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> ciudades<span style="color: #66cc66;">&#41;</span>;</p>
	<p><span style="color: #993333;">int</span> main<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> argc, <span style="color: #993333;">char</span> </strong>argv<span style="color: #66cc66;">&#41;</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; <span style="color: #993333;">int</span> numCiudades = <span style="color: #cc66cc;">0</span> ;<br />
&#160; &#160; <span style="color: #993333;">int</span> result = <span style="color: #cc66cc;">0</span>;<br />
&#160; &#160; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>argc&gt;<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>&#160; &#160; &#160; &#160; <br />
&#160; &#160; &#160; &#160; numCiudades = atoi<span style="color: #66cc66;">&#40;</span>argv<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; <span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Ciudades:"</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; scanf<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"%d"</span>, &amp;numCiudades<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; <span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; <br />
&#160; &#160; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>numCiudades&gt;<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; ferroviaria<span style="color: #66cc66;">&#40;</span>numCiudades<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; <span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Introduzca más de una ciudad"</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; <span style="color: #66cc66;">&#125;</span><br />
&#160;<span style="color: #66cc66;">&#125;</span><br />
&#160;<br />
&#160;<span style="color: #993333;">int</span> ferroviaria<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> numCiudades<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160;<span style="color: #993333;">int</span> i = <span style="color: #cc66cc;">0</span>;<br />
&#160; &#160; &#160;<span style="color: #993333;">int</span> j = <span style="color: #cc66cc;">0</span>;<br />
&#160; &#160; &#160;<span style="color: #993333;">char</span> *ciudades<span style="color: #66cc66;">&#91;</span>numCiudades<span style="color: #66cc66;">&#93;</span>;<br />
&#160; &#160; &#160;<span style="color: #993333;">char</span> ciudad<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1024</span><span style="color: #66cc66;">&#93;</span>;<br />
&#160; &#160; &#160;strcpy<span style="color: #66cc66;">&#40;</span>ciudad, <span style="color: #ff0000;">""</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160;<span style="color: #993333;">int</span> *rutas = <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> *<span style="color: #66cc66;">&#41;</span>malloc<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">sizeof</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span>*numCiudades*numCiudades<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; <br />
&#160; &#160; &#160;<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span>i=<span style="color: #cc66cc;">0</span>; i&lt;numCiudades; i++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160;<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\n</span>Ciudad [ %d ]"</span>, i+<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>&#160; &#160;;<br />
&#160; &#160; &#160; &#160; &#160;gets<span style="color: #66cc66;">&#40;</span>ciudad<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160;ciudades<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> = <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">char</span> *<span style="color: #66cc66;">&#41;</span>malloc<span style="color: #66cc66;">&#40;</span>strlen<span style="color: #66cc66;">&#40;</span>ciudad<span style="color: #66cc66;">&#41;</span>*<span style="color: #993333;">sizeof</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">char</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160;strcpy<span style="color: #66cc66;">&#40;</span>ciudades<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>, ciudad<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160;<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span>j=<span style="color: #cc66cc;">0</span>;j&lt;numCiudades;j++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; rutas<span style="color: #66cc66;">&#91;</span> <span style="color: #66cc66;">&#40;</span>i*numCiudades<span style="color: #66cc66;">&#41;</span>+j<span style="color: #66cc66;">&#93;</span> = rand<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>%<span style="color: #cc66cc;">2</span>;<span style="color: #808080; font-style: italic;">//1 si hay conexion de ruta, 0 no hay ruta de conexión</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>rutas<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#40;</span>j*numCiudades<span style="color: #66cc66;">&#41;</span>+i<span style="color: #66cc66;">&#93;</span>==<span style="color: #cc66cc;">1</span>|| rutas<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#40;</span>j*numCiudades<span style="color: #66cc66;">&#41;</span>+i<span style="color: #66cc66;">&#93;</span>==<span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; rutas<span style="color: #66cc66;">&#91;</span> <span style="color: #66cc66;">&#40;</span>i*numCiudades<span style="color: #66cc66;">&#41;</span>+j<span style="color: #66cc66;">&#93;</span> =rutas<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#40;</span>j*numCiudades<span style="color: #66cc66;">&#41;</span>+i<span style="color: #66cc66;">&#93;</span>;&#160; &#160; &#160; <br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; &#160; &#160; &#160;<span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; &#160;<span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; &#160;<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\n</span>Tabla de Ciudades y Rutas<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span>"</span><span style="color: #66cc66;">&#41;</span>;&#160; &#160; &#160; &#160;<br />
&#160; &#160; &#160;<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span>i= <span style="color: #cc66cc;">0</span>; i&lt;numCiudades; i++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160;<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"%s<span style="color: #000099; font-weight: bold;">\t</span>"</span>, ciudades<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;&#160; &#160; &#160; &#160;<br />
&#160; &#160; &#160;<span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; &#160;<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\n</span>"</span><span style="color: #66cc66;">&#41;</span>;&#160; &#160; &#160; &#160;<br />
&#160; &#160; &#160;<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span>i= <span style="color: #cc66cc;">0</span>; i&lt;numCiudades; i++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"%s<span style="color: #000099; font-weight: bold;">\t</span>"</span>, ciudades<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span>j= <span style="color: #cc66cc;">0</span>; j&lt;numCiudades; j++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"%d<span style="color: #000099; font-weight: bold;">\t</span> "</span>, rutas<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#40;</span>i*numCiudades<span style="color: #66cc66;">&#41;</span>+j<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\n</span>"</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160;<span style="color: #66cc66;">&#125;</span>&#160; &#160; &#160;</p>
	<p>&#160; &#160; &#160;<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\n</span>Detalles de Ciudades y Rutas<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>"</span><span style="color: #66cc66;">&#41;</span>;&#160; &#160; &#160; &#160;<br />
&#160; &#160; &#160;<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span>i= <span style="color: #cc66cc;">0</span>; i&lt;numCiudades; i++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"%s Conexiones: <span style="color: #000099; font-weight: bold;">\n</span>"</span>, ciudades<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span>j= <span style="color: #cc66cc;">0</span>; j&lt;numCiudades; j++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>rutas<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#40;</span>i*numCiudades<span style="color: #66cc66;">&#41;</span>+j<span style="color: #66cc66;">&#93;</span>==<span style="color: #cc66cc;">1</span> &amp;&amp; i!=j<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"%s<span style="color: #000099; font-weight: bold;">\t</span>"</span>, ciudades<span style="color: #66cc66;">&#91;</span>j<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;<span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>"</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160;<span style="color: #66cc66;">&#125;</span>&#160; &#160; &#160;<br />
&#160; &#160; &#160;getch<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;&#160; &#160; &#160;<br />
&#160;<span style="color: #66cc66;">&#125;</span></p>
	<p>
&#160;</div></div>
	<li>9.- Visualizar la matriz transpuesta de una matriz M de 6 x 7 elementos.
<div class="code"><div class="c">
<span style="color: #339933;">#include &lt;stdio.h&gt;</span><br />
<span style="color: #339933;">#include &lt;stdlib.h&gt;</span><br />
<span style="color: #339933;">#include &lt;string.h&gt;</span><br />
<span style="color: #339933;">#include &lt;conio.h&gt;</span><br />
<span style="color: #993333;">void</span>&#160; &#160;transpuesta<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> m, <span style="color: #993333;">int</span> n <span style="color: #66cc66;">&#41;</span>;</p>
	<p><span style="color: #993333;">int</span> main<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> argc, <span style="color: #993333;">char</span> <strong>argv<span style="color: #66cc66;">&#41;</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; <span style="color: #993333;">int</span> m = <span style="color: #cc66cc;">0</span> ;<br />
&#160; &#160; <span style="color: #993333;">int</span> n = <span style="color: #cc66cc;">0</span>;<br />
&#160; &#160; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>argc&gt;<span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>&#160; &#160; &#160; &#160; <br />
&#160; &#160; &#160; &#160; m = atoi<span style="color: #66cc66;">&#40;</span>argv<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; n = atoi<span style="color: #66cc66;">&#40;</span>argv<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; <span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Filas(m):"</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; scanf<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"%d"</span>, &amp;m<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; <br />
&#160; &#160; &#160; &#160; &#160; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Columans(n):"</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; scanf<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"%d"</span>, &amp;n<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; <span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; &#160;transpuesta<span style="color: #66cc66;">&#40;</span>m,n<span style="color: #66cc66;">&#41;</span>;<br />
&#160;<span style="color: #66cc66;">&#125;</span></p>
	<p>
&#160;<span style="color: #993333;">void</span>&#160; transpuesta<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> m, <span style="color: #993333;">int</span> n <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160;<span style="color: #993333;">int</span> i,j;<br />
&#160; &#160; &#160; &#160; &#160;<span style="color: #993333;">int</span> *values = <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> *<span style="color: #66cc66;">&#41;</span>malloc<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">sizeof</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span>*m*n<span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160;<span style="color: #993333;">int</span> *mTranspuesta = <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> *<span style="color: #66cc66;">&#41;</span>malloc<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">sizeof</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span>*n*m<span style="color: #66cc66;">&#41;</span>;</p>
	<p>&#160; &#160; &#160; &#160; &#160;<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\n</span> matriz original<span style="color: #000099; font-weight: bold;">\n</span>"</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160;<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>i = <span style="color: #cc66cc;">0</span>; i&lt;m; i++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160;<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>j=<span style="color: #cc66cc;">0</span>;j&lt;n;j++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;values<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#40;</span>i*n<span style="color: #66cc66;">&#41;</span>+j<span style="color: #66cc66;">&#93;</span> =&#160; values<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> = <span style="color: #66cc66;">&#40;</span>rand<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>%<span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span>;<span style="color: #808080; font-style: italic;">//numeros aleatorios entre 0 y 99;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;mTranspuesta<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#40;</span>j*m<span style="color: #66cc66;">&#41;</span>+i<span style="color: #66cc66;">&#93;</span> =&#160; values<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#40;</span>i*n<span style="color: #66cc66;">&#41;</span>+j<span style="color: #66cc66;">&#93;</span> ;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"%d, "</span>, values<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#40;</span>i*n<span style="color: #66cc66;">&#41;</span>+j<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160;<span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160;<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\n</span>"</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160;<span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; &#160; &#160; &#160;<br />
&#160; &#160; &#160; &#160; &#160;<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\n</span> Matriz Transpuesta<span style="color: #000099; font-weight: bold;">\n</span>"</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160;<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>i = <span style="color: #cc66cc;">0</span>; i&lt;n; i++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160;<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>j=<span style="color: #cc66cc;">0</span>;j&lt;m;j++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"%d, "</span>, mTranspuesta<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#40;</span>i*m<span style="color: #66cc66;">&#41;</span>+j<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160;<span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160;<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\n</span>"</span><span style="color: #66cc66;">&#41;</span>;<br />
&#160; &#160; &#160; &#160; &#160;<span style="color: #66cc66;">&#125;</span><br />
&#160; &#160; &#160; &#160; &#160;getch<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;&#160; &#160; &#160; &#160; &#160;<br />
&#160; &#160; &#160; &#160; <br />
&#160; &#160; <span style="color: #66cc66;">&#125;</span></p>
	<p>&#160;</div></div>
	<li>10.- Una empresa de venta de productos por correo desea realizar una estadística de las ventas realizadas de cada uno de los productosa lo largo del año. Distribuye un total de 100 productos, por lo que las ventas se pueden almacenar en una tabla de 100 filas y 12 columnas. Se desea conocer:
	<li>a) El total de venta de cada uno de los productos.
	<li>b) El total de ventas de cada mes.
	<li>c) El producto más vendido de cada mes.
	<li>d) El nombre, el mes y la cantidad de producto más vendido.
<div class="code"><div class="c">
<span style="color: #339933;">#include &lt;stdio.h&gt;</span><br />
<span style="color: #339933;">#include &lt;stdlib.h&gt;</span><br />
<span style="color: #339933;">#include &lt;string.h&gt;</span><br />
<span style="color: #339933;">#include &lt;conio.h&gt;