Menú

Mostrar Mensajes

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

Mostrar Mensajes Menú

Mensajes - Dawman

#11
Scripting / javascript
30 Septiembre 2013, 23:03 PM
Hola,
Estoy ententando crear un script para pintar las celdas de una tabla con los colores que el usuario seleciona, cada colo se ira repitiendo tantas veces como el usurio marca... he hecho algo per no me funiona!
necesito vuestra ayuda!! gracias
Código (html4strict) [Seleccionar]
<html>
<head>
<title> Pràctica I </title>
<link rel="stylesheet" href="css.css"></style>
<meta HTTP-EQUIV="CONTENT-TYPE" content="text/html; charset=UTF-8"/>
       <script>            // generar taula          
           function crearTaula()
           {
               var fons1 = document.getElementById("color1").value;
               var fons2 = document.getElementById("color2").value;
               var fons3 = document.getElementById("color3").value;
               var val1 = document.getElementById("valor1").value;
               var val2 = document.getElementById("valor2").value;
               var val3 = document.getElementById("valor3").value;
               var v1 = val1;
               var v2 = val2;
               var v3 = val3;
               var cont = 0;
               var gran = false;
               document.write("<table>");
               for (i = 0; i < 20; i++) // per generar files
               {
                   document.write("<tr>");
                   for (j = 0; j < 20;  j++) // per generar cel·les
                   {
                       if (!gran) {
                           cont = val1;
                           val1 = val2;
                           val2 = val3;
                           val3 = cont;
                           x = 0;
                       }
                       for (x; x < cont; x++) // valor primer input...
                       {
                           if (cont == v1) document.write("<td bgcolor=\"" + fons1 + "\"></td>")
                           else if (cont == v2) document.write("<td bgcolor=\"" + fons2 + "\"></td>")
                           else if (cont == v3) document.write("<td bgcolor=\"" + fons3 + "\"></td>")    
                       }
                     
                       if (j >= 20)
                       {
                           gran = true;
                           break;
                       }          
                   }
                   document.write("</tr>");
               }
               document.write("</table>");
           }
</script>
</head>      
<body>      
<h1>PRÀCTICA 1</h1>
<select id="color1">
           <option value="red">Vermell</option>
           <option value="green">Verd</option>
           <option value="blue">Blau</option>
           <option value="yellow">Groc</option>
           <option value="orange">Taronja</option>
           <option value="purple">Magenta</option>
           <option value="cyan">Cian</option>
</select>
       <input id="valor1"> repeticions<br />        
       <select id="color2">
           <option value="red">Vermell</option>
           <option value="green">Verd</option>
           <option value="blue">Blau</option>
           <option value="yellow">Groc</option>
           <option value="orange">Taronja</option>
           <option value="purple">Magenta</option>
           <option value="cyan">Cian</option>
</select>
        <input id="valor2"> repeticions<br />      
       <select id="color3">
           <option value="red">Vermell</option>
           <option value="green">Verd</option>
           <option value="blue">Blau</option>
           <option value="yellow">Groc</option>
           <option value="orange">Taronja</option>
           <option value="purple">Magenta</option>
           <option value="cyan">Cian</option>
</select>
       <input id="valor3"> repeticions<br />
       <button onClick="crearTaula();">Pintar</button>
       
   </body>
</html>





[MOD]: USA LAS ETIQUETAS PARA INSERTAR CÓDIGO

#12
Programación C/C++ / Re: Recursividad c#
4 Mayo 2013, 18:35 PM
Cita de: $Edu$ en  4 Mayo 2013, 14:39 PM
No se hacen tareas aca, asi que podrias dejarnos tu intento o tu idea. Yo la verdad que pensandolo solamente no doy con la solucion, porque nunca en mi vida haria eso recursivamente, no es necesario, pero se ve que te lo ha pedido un profesor de esos que odias todo el año xD

NO TRATABA DE QUE ME HAGAN LAS TAREAS, BUSCABA AYUDA QUE AQUI NO HE ENCONTRADO... PERO AUNQUE ME COSTO 2 DIAS DAR CON LA SOLUCIÓN, LO HICE YO MISMO!!!
ESTA ES UNA SOLUCION... SE PUEDE OPTIMIZAR!!

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

namespace ex1_recurs
{
    class Program
    {       
       
        static int separar(int num3)
        {
            Console.Write((num3 % 10) + " ");
            if (num3 / 10 == 0) return num3;

            else return separar(num3 / 10);
        }

        static void Main(string[] args)
        {
            int num;
            Console.WriteLine("Escriu un numero");
            num = Convert.ToInt32(Console.ReadLine());
            while(num<0)
                    {
                         Console.WriteLine("Escriu un numero");
                         num = Convert.ToInt32(Console.ReadLine());
                    }
                   
            String num2 = "";
            String aux = "";
            String nbre = Convert.ToString(num);           
            for (int j = nbre.Length - 1; j >= 0; j--)
            {
                aux = Convert.ToString(nbre[j]);
                num2 = num2 + aux;
            }
           
            int num3 = Convert.ToInt32(num2);
            separar(num3);
            Console.WriteLine();
           
        }
    }
}
#13
Programación C/C++ / Re: Recursividad c#
4 Mayo 2013, 17:17 PM
Cita de: cypascal en  4 Mayo 2013, 13:55 PM
¿Pero si mañana es domingo?

Hay que entragarlo via Moodel esta noche!!
#14
Programación C/C++ / Re: Recursividad c#
4 Mayo 2013, 17:15 PM
Yo he puesto esto, el problema es q me invierte el numero!!

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

namespace ex1_recurs
{
    class Program
    {
        static int separar(int num)
        {
            Console.Write((num %10) + " ");
            if (num / 10 == 0) return num;
           
            else return separar(num/10);
       
        }
        static void Main(string[] args)
        {
            int num;
            Console.WriteLine("Escriu un numero");
            num = Convert.ToInt32(Console.ReadLine());
            while(num<0)
                    {
                         Console.WriteLine("Escriu un numero");
                         num = Convert.ToInt32(Console.ReadLine());
                    }
                   
            separar(num);
            Console.WriteLine();
            Console.ReadKey();
        }
    }
}
#15
Programación C/C++ / Re: Recursividad c#
4 Mayo 2013, 12:26 PM
Es urgente!! lo necesito para esta noche!!
#16
Programación C/C++ / Recursividad c#
3 Mayo 2013, 16:19 PM
Escribe una acción recursiva en c# que escriba los dígitos enter n (n>0) en el mismo orden pero, separados por en espacio.
por ejemplo: si n=8956, hay que devolver 8 9 5 6

Alguna ayudita???