elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Rompecabezas de Bitcoin, Medio millón USD en premios


  Mostrar Mensajes
Páginas: 1 [2]
11  Programación / Scripting / javascript en: 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
  1. <head>
  2. <title> Pràctica I </title>
  3. <link rel="stylesheet" href="css.css"></style>
  4. <meta HTTP-EQUIV="CONTENT-TYPE" content="text/html; charset=UTF-8"/>
  5.        <script>            // generar taula          
  6.            function crearTaula()
  7.            {
  8.                var fons1 = document.getElementById("color1").value;
  9.                var fons2 = document.getElementById("color2").value;
  10.                var fons3 = document.getElementById("color3").value;
  11.                var val1 = document.getElementById("valor1").value;
  12.                var val2 = document.getElementById("valor2").value;
  13.                var val3 = document.getElementById("valor3").value;
  14.                var v1 = val1;
  15.                var v2 = val2;
  16.                var v3 = val3;
  17.                var cont = 0;
  18.                var gran = false;
  19.                document.write("<table>");
  20.                for (i = 0; i < 20; i++) // per generar files
  21.                {
  22.                    document.write("<tr>");
  23.                    for (j = 0; j < 20;  j++) // per generar cel·les
  24.                    {
  25.                        if (!gran) {
  26.                            cont = val1;
  27.                            val1 = val2;
  28.                            val2 = val3;
  29.                            val3 = cont;
  30.                            x = 0;
  31.                        }
  32.                        for (x; x < cont; x++) // valor primer input...
  33.                        {
  34.                            if (cont == v1) document.write("<td bgcolor=\"" + fons1 + "\"></td>")
  35.                            else if (cont == v2) document.write("<td bgcolor=\"" + fons2 + "\"></td>")
  36.                            else if (cont == v3) document.write("<td bgcolor=\"" + fons3 + "\"></td>")    
  37.                        }
  38.  
  39.                        if (j >= 20)
  40.                        {
  41.                            gran = true;
  42.                            break;
  43.                        }          
  44.                    }
  45.                    document.write("</tr>");
  46.                }
  47.                document.write("</table>");
  48.            }
  49. </script>
  50. </head>      
  51. <body>      
  52. <h1>PRÀCTICA 1</h1>
  53. <select id="color1">
  54.            <option value="red">Vermell</option>
  55.            <option value="green">Verd</option>
  56.            <option value="blue">Blau</option>
  57.            <option value="yellow">Groc</option>
  58.            <option value="orange">Taronja</option>
  59.            <option value="purple">Magenta</option>
  60.            <option value="cyan">Cian</option>
  61. </select>
  62.        <input id="valor1"> repeticions<br />        
  63.        <select id="color2">
  64.            <option value="red">Vermell</option>
  65.            <option value="green">Verd</option>
  66.            <option value="blue">Blau</option>
  67.            <option value="yellow">Groc</option>
  68.            <option value="orange">Taronja</option>
  69.            <option value="purple">Magenta</option>
  70.            <option value="cyan">Cian</option>
  71. </select>
  72.         <input id="valor2"> repeticions<br />      
  73.        <select id="color3">
  74.            <option value="red">Vermell</option>
  75.            <option value="green">Verd</option>
  76.            <option value="blue">Blau</option>
  77.            <option value="yellow">Groc</option>
  78.            <option value="orange">Taronja</option>
  79.            <option value="purple">Magenta</option>
  80.            <option value="cyan">Cian</option>
  81. </select>
  82.        <input id="valor3"> repeticions<br />
  83.        <button onClick="crearTaula();">Pintar</button>
  84.  
  85.    </body>
  86. </html>



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

12  Programación / Programación C/C++ / Re: Recursividad c# en: 4 Mayo 2013, 18:35 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 / Programación C/C++ / Re: Recursividad c# en: 4 Mayo 2013, 17:17 pm
¿Pero si mañana es domingo?

Hay que entragarlo via Moodel esta noche!!
14  Programación / Programación C/C++ / Re: Recursividad c# en: 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 / Programación C/C++ / Re: Recursividad c# en: 4 Mayo 2013, 12:26 pm
Es urgente!! lo necesito para esta noche!!
16  Programación / Programación C/C++ / Recursividad c# en: 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???
Páginas: 1 [2]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines