Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
//NEW Y DELETE//
#include "stdafx.h"
#include <iostream>
#include <conio.h>
int main()
{
//asignamos memoria
float *punteroA = new float;
float *punteroB = new float;
float *suma = new float;
float *producto = new float;
cout << "el valor de la suma es: " << *suma << endl;
cout << "el valor del producto es: " << *producto << endl;
_getch();
return 0;
}
-----------------------------------------------------------------------------------------
// ConsoleApplication1.cpp : main project file.
#include "stdafx.h"
#include <iostream>
#include <conio.h>
int main()
{
int *punteroA;
*punteroA = 5;
cout << "el valor de la variable referenciada por el puntero es: " << *punteroA <<
endl;
delete punteroA;
punteroA = NULL;
_getch();
return 0;
}
-----------------------------------------------------------------------------------------
// ConsoleApplication1.cpp : main project file.
#include "stdafx.h"
#include <iostream>
#include <conio.h>
int main()
{
if (*punteroA == NULL)
cout << "no se pudo reservar espacio en la memoria";
else
{
cout << "ingrese un numero: ";
cin >> *punteroA;
*punteroA = *punteroA + 5;
cout << "el nuevo numero es: " << *punteroA << endl;
//liberamos memoria
delete punteroA;
}
_getch();
return 0;
}
-----------------------------------------------------------------------------------------
// ConsoleApplication1.cpp : main project file.
#include "stdafx.h"
#include <iostream>
#include <conio.h>
//funcion factorial
*elfactorial = 1;
*contador = 1;
*suma = 1;
//Dibujarel Rombo,;;
void Dibuja(int *numRombo)
{
int *fila = new int;
int *columna = new int;
int *cantFilas = new int;
int *numero = new int; //los numeros que se impriman
int *posX = new int;
int *posY = new int;
int *cantCaracteres = new int;
int *posCursor = new int;
Console::Clear();
*cantFilas = (*numRombo * 2) - 1;
*posX = 40;
*posY = 10;
*posCursor = 0; //esta variable manejará la posicion del cursor en el eje
X
*cantCaracteres = 1;
//la logica
*numero = 1;
int main()
{
int *opcion = new int;
int *elfactorial = new int;
int *numero = new int;
int *k = new int;
int *numRombo = new int;
float *elexponencial = new float;
float *a = new float;
while (1)
{
cout << "MENU PRINCIPAL" << endl;
cout << "1) determinar el factorial" << endl;
cout << "2) Calcular el valor del exponencial" << endl;
cout << "3) impriir el rombo" << endl;
cout << "4) Salir" << endl;
while (1)
{
cout << "ingresar opcion";
cin >> *opcion;
if (*opcion == 1 || *opcion == 2 || *opcion == 3 || *opcion == 4)
break;
}
while (1)
{
cout << "ingrese el valor de k: ";
cin >> *k;
}
else
{
while (1)
{
cout << "ingrese un valor entre 1 y 10: ";
cin >> *numRombo;
if (*numRombo > 0 && *numRombo < 11);
break;
}
Dibuja(numRombo);
cout << endl << endl;
}
}
}
//liberamos memoria
delete opcion;
delete elfactorial;
delete numero;
delete k;
delete numRombo;
delete elexponencial;
delete a;
opcion = NULL;
elfactorial = NULL;
numero = NULL;
k = NULL;
numRombo = NULL;
elexponencial = NULL;
a = NULL;
_getch();
return 0;
}
-----------------------------------------------------------------------------------------
// ConsoleApplication2.cpp : main project file.
#include "stdafx.h"
#include <iostream>
#include <conio.h>
}
void ImprimirNumerosComplejos(int *parteReal1, int *parteImaginaria1, int *parteReal2,
int *parteImaginaria2)
{
if (*parteImaginaria1 < 0)
cout << "(" << *parteReal1 << *parteImaginaria1 << "i" << ")" << endl;
else
{
cout << "(" << *parteReal1 << "+" << *parteImaginaria1 << "i" << ")" <<
endl;
}
if (*parteImaginaria2 < 0)
cout << "(" << *parteReal2 << *parteImaginaria2 << "i" << ")" << endl;
else
{
cout << "(" << *parteReal2 << "+" << *parteImaginaria2 << "i" << ")" <<
endl;
}
}
int main()
{
char *opcion = new char;
int *parteReal1 = new int;
int *parteImaginaria1 = new int;
int *parteReal2 = new int;
int *parteImaginaria2 = new int;
while (1)
{
cout << "MENU" << endl;
cout << "A) Sumar 2 numeros complejos" << endl;
cout << "B) Restar 2 numeros complejos" << endl;
cout << "X) Salir del programa" << endl;
while (1)
{
cout << "ingresar opcion: ";
cin >> *opcion;
}
}
_getch();
return 0;
}