método que apila pilas, recibiendo como párametro una pila
public void apila(Pila p){
while (!p.empty())
this.push(p.pop());
}
All generations.
public void apila(Pila p){
while (!p.empty())
this.push(p.pop());
}
public class Apilador {
public static Pila apila(Pila pila){
if (pila.estaVacia()){
return pila;
} else {
apila(pila.desapilar());
Pila pila2 = new Pila();
pila2.apilar(pila.tope());
return pila2;
}
}
}
Script
var miObjeto = {
a: 1,
b: 2
}
function imprimirProps(obj) {
console.log(obj.a, obj.b)
}
imprimirProps(miObjeto);
public Stack<Integer> apilar(Stack<Integer> pila) {
//Pasa la pila al inicio de la pila
//Puedes usar el método push de la clase Stack
return pila;
}
void copyQueue(Queue q1, Queue q2){
Queue copy1 = new Queue();
Queue copy2 = new Queue();
while(!q1.isEmpty()){
copy1.enqueue(q1.dequeue());
}
while(!q1.isEmpty()){
q1.enqueue(copy1.dequeue());
}
while(!q2.isEmpty()){
copy2.enqueue(q2.dequeue());
}
while(!copy2.isEmpty()){
q2.enqueue(copy2.dequeue());
q1.enqueue(copy2.dequeue());
}
}
Script
const stack = []
function push(stack, item) {
stack = [item, ...stack]
return stack
}
push(stack, 'one')
push(stack, 'two')
public static Stack<Integer> addStack(Stack<Integer> stack) {
Stack<Integer> aux1 = new Stack<Integer>();
Stack<Integer> aux2 = new Stack<Integer>();
while(!stack.empty()){
aux1.push(stack.pop());
}
while(!aux1.empty()){
int num = aux1.pop();
aux2.push(num);
stack.push(num);
}
return aux2;
}
void apilar(Stack<Integer> pila){
if (!pila.isEmpty()) {
int n = pila.pop();
apilar(pila);
pila.push(n);
}
}
public static void apilarPilas(Stack<Integer> pila1, Stack<Integer> pila2){
Stack<Integer> pila3 = new Stack<Integer>();
while(!pila1.isEmpty())
pila3.push(pila1.pop());
while(!pila2.isEmpty())
pila3.push(pila2.pop());
while(!pila3.isEmpty())
pila1.push(pila3.pop());
}
Script
function imprimir(personas){
console.log(personas.nombre, personas.apellido);
}
function imprimir2(personas){
console.log(personas.nombre + " " + personas.apellido);
}
imprimir(personas);
imprimir2(personas);
// Output:
// Maria Fernanda
// Maria Fernanda
def stackpile(pila, pila2):
pila2.push(pila.pop())
return pila2
stackpile(pila1, pila2)
void clavesOrdenadas(map<int, vector<int> > &dic){
typedef map<int, vector<int> >::value_type pair_t;
vector<pair_t> ordered(dic.begin(), dic.end());
sort(ordered.begin(), ordered.end(), comparator);
for (int i = 0; i < ordered.size(); i++) {
cout << ordered[i].first << endl;
}
}
bool comparator(pair_t a, pair_t b) {
return a.first < b.first;
}
public static void CopiaCola(Cola c){
Cola colaNueva = new Cola();
while(!c.esVacia()){
colaNueva.push(c.pop());
}
return colaNueva;
}
public void stack(Stack<Integer> s) {
s.push(4);
}
Stack<Integer> stack = new Stack<>();
stack(stack);
stack;
public class Respuesta {
public boolean correcto;
public int dato;
}
public class ConjuntoEspecialTDA {
public boolean inicializar();
public boolean agregar(int x);
public Respuesta eliminar(int x);
public Respuesta eliminarMayor();
public Respuesta eliminarMenor();
public void vaciar();
}
private void apilarPilas(Stack<Integer> pilaAuxiliar, Stack<Integer> pilaAuxiliar2) {
while (!pilaAuxiliar.empty())
pilaAuxiliar2.push(pilaAuxiliar.pop());
}
// code
public void push(Stack s) {
s.push(this.pop());
}
public static void clavesOrdenadas(Map<Clave, Object> m) {
TreeMap<Clave, Object> ordenado = new TreeMap<Clave, Object>(m);
System.out.println("Claves en orden alfabético");
for (Clave clave : ordenado.keySet()) {
System.out.println(clave);
}
}
Script
function add(a, b){
return a.concat(b)
}
add([1, 2, 3], [4, 5, 6])
class ConjuntoEspecialTDA {
constructor() {
this.conjunto = new ConjuntoTDA();
};
agregar(elem) {
if (this.esta(elem)) {
return new Respuesta(false, null);
}
this.conjunto.agregar(elem);
return new Respuesta(true, null);
}
sacar(elem) {
if (!this.esta(elem)) {
return new Respuesta(false, null);
}
this.conjunto.sacar(elem);
return new Respuesta(true, null);
}
esta(elem) {
return this.conjunto.esta(elem);
}
card() {
return this.conjunto.card();
}
esVacio() {
return this.conjunto.esVacio();
}
pertenec
public void apilarPila(Stack pila) {
// Apilamos los elementos de la pila original en la pila de la clase
while(!pila.empty()) {
this.pila.push(pila.pop());
}
}
function ConjuntoEspecialTDA(){
var elementos = 0;
var conjunto = new Array();
var vacio = true;
var retorno = new Respuesta();
function esVacio(){
return vacio;
}
function agregar(elem){
var existe = false;
var i = 0;
while (i < elementos && !existe){
if (conjunto[i] == elem){
existe = true;
}
i++;
}
if (!existe){
conjunto[elementos] = elem;
vacio = false;
elementos++;
retorno.setCorrecto(true);
}
}
function eliminar(elem){
var i = 0;
while (i < elementos){
if (conjunto[i] == elem){
for (i; i < elementos-1; i++){
conjunto[i] = conjunto
package com.example;
import javax.swing.*;
import java.awt.*;
public class Form extends JFrame {
public Form() {
super("Form");
setLayout(new FlowLayout());
this.add(new JLabel("Name"));
this.add(new JTextField(20));
this.add(new JLabel("Lastname"));
this.add(new JTextField(20));
this.add(new JLabel("Email"));
this.add(new JTextField(20));
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(300, 300);
setVisible(true);
}
public static void main(String[] args) {
new Form();
}
}
public class MyPanel extends JPanel {
public MyPanel() {
JLabel label = new JLabel("Name: ");
JTextField textField = new JTextField(10);
add(label);
add(textField);
}
var ConjuntoEspecialTDA = {
create: function() {
var conjunto = ConjuntoTDA.create();
conjunto.agregar = function(elemento) {
var respuesta = Respuesta.create();
if (elemento in this.elementos) {
respuesta.correcto = false
respuesta.info = 'Elemento ya existente'
} else {
this.elementos[elemento] = 1
respuesta.correcto = true
respuesta.info = 'Elemento agregado'
}
return respuesta
}
conjunto.borrar = function(elemento) {
var respuesta = Respuesta.create();
if (!(elemento in this.elementos)) {
respuesta.correcto = false
respuesta.info = 'Elemento no existente'
} else {
delete this.elementos[elemento]
respuesta.correcto = true
resp
Script
function pileUp(stack) {
var stackLength = stack.length;
var newStack = [];
for(var i = 0; i < stackLength; i++) {
newStack.push(stack.shift());
}
return newStack;
}
pileUp([3, 2, 1]);
Generate
More than just a code generator. A tool that helps you with a wide range of tasks. All in one place.
Function from Description
Text Description to SQL Command
Translate Languages
Generate HTML from Description
Code to Explanation
Fix invalid Code
Get Test for Code
Class from Description
Regex from Description
Regex to Explanation
Git Command from Description
Linux Command
Function from Docstring
Add typing to code
Get Language from Code
Time complexity
CSS from Description
Meta Tags from Description