This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
void intercambiar_int (int *a, int *b) { | |
int tmp; | |
tmp = *a; | |
*a = *b; | |
*b = tmp; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
set_time_limit(0); | |
ini_set('memory_limit','128M'); | |
function burbuja ($v,&$metodo) { | |
$tmp = $v[0]; | |
$N = count($v); | |
$metodo['burbuja']['tiempo'] = microtime(true); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <stdlib.h> | |
using namespace std; | |
// copiar un array en otro | |
// si *copia es NULL, se aloja memoria para guardarlo | |
double *copiar (double *array, double *copia, unsigned long longitud) { | |
if (!copia) { | |
copia = (double *)calloc(longitud,sizeof(double)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <stdlib.h> | |
using namespace std; | |
// copiar un array en otro | |
// si *copia es NULL, se aloja memoria para guardarlo | |
double *copiar (double *array, double *copia, unsigned long longitud) { | |
if (!copia) { | |
copia = (double *)calloc(longitud,sizeof(double)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
/*#define TECLA_ARRIBA 72*/ | |
/*#define TECLA_ABAJO 80*/ | |
/* El programa fue probado a través de SSH, no funcionan las flechas */ | |
#define TECLA_ARRIBA 'r' | |
#define TECLA_ABAJO 'b' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void agregar_nueva_linea () { | |
segmento *ultimo_segmento; | |
char linea[ANCHO_LINEA]; | |
int continuar = 1; | |
while (continuar) { | |
fgets(linea,ANCHO_LINEA,stdin) | |
/* Si hay una nueva línea, es que acabamos de procesar el texto */ | |
if (linea[strlen(linea) - 1] == '\n') { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Event < ActiveRecord::Base | |
attr_accessible :_timed, :details, :end_date, :start_date, :text | |
# From http://www.dhtmlx.com/docs/products/dhtmlxScheduler/xml/events.xml | |
def to_xml (options = {}) | |
options[:indent] ||= 2 | |
xml = options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent]) | |
xml.instruct! unless options[:skip_instruct] | |
xml.event(:id => id, :timed => _timed) do | |
xml.text text |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Album < ActiveRecord::Base | |
has_many :images | |
belongs_to :gallery, :polymorphic => true | |
attr_accessible :title | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Collection extends ArrayIterator { | |
public function map ($closure=FALSE) { | |
$copy = $this->getArrayCopy(); | |
if (is_string($closure)) { | |
$copy = array_map(function($value)use($closure){ | |
$function = function(){}; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
mysql_connect('localhost','root',''); | |
mysql_select_db('test'); | |
mysql_query("CREATE TABLE IF NOT EXISTS comentarios (id INT(11) NOT NULL AUTO_INCREMENT, comment TEXT, fecha TIMESTAMP, PRIMARY KEY(id))"); | |
$dato = $_POST['TxtboxCmtar']; | |
if (validar_usuario() && es_texto($dato)) { // En PHP, para comprobar una cadena, generalmente esa cadena es enviada a una función, como argumento |