Ensayo Calculadora gráfica para Dev-C
Enviado por Mario Hernández • 16 de Enero de 2016 • Tarea • 1.496 Palabras (6 Páginas) • 377 Visitas
#include <winbgim.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char resul[15]="0";
void menu();
void waitForLeftMouseClick();
void grafico();
main(){
menu();
return 0;
}
void grafico(){
initwindow(340,500);
setcolor(4);
rectangle(20,100,80,160);//"Vaciar" la pantalla.
outtextxy(26,118,"CLS");
rectangle(100,100,160,160);//Cambia el signo al número que se está introduciendo
outtextxy(122,118,"±");
rectangle(180,100,240,160);//Divide uno entre el número que se está introduciendo
outtextxy(186,118,"1/x");
rectangle(260,100,320,160);//borrar último dígito
outtextxy(266,118,"DEL");
setcolor(15);
rectangle(20,180,80,240);//7
outtextxy(42,198,"7");
rectangle(20,260,80,320);//4
outtextxy(42,278,"4");
rectangle(20,340,80,400);//1
outtextxy(42,358,"1");
rectangle(20,420,80,480);//0
outtextxy(42,438,"0");
rectangle(100,180,160,240);//8
outtextxy(122,198,"8");
rectangle(100,260,160,320);//5
outtextxy(122,278,"5");
rectangle(100,340,160,400);//2
outtextxy(122,358,"2");
rectangle(180,180,240,240);//9
outtextxy(202,198,"9");
rectangle(180,260,240,320);//6
outtextxy(202,278,"6");
rectangle(180,340,240,400);//3
outtextxy(202,358,"3");
setcolor(3);
rectangle(260,180,320,240);//División
outtextxy(282,198,"÷");
rectangle(260,260,320,320);//Multiplicación
outtextxy(282,278,"+");
rectangle(260,340,320,400);//Resta
outtextxy(282,358,"*");
rectangle(260,420,320,480);//Suma
outtextxy(282,438,"-");
setcolor(15);
rectangle(100,420,160,480);//Punto decimal
outtextxy(122,438,".");
rectangle(180,420,240,480);//Igual
outtextxy(202,438,"=");
setcolor(15);
settextstyle(4,180,4);
outtextxy(300,95,resul);
}
void waitForLeftMouseClick(){
clearmouseclick(WM_LBUTTONDOWN);
const int DELAY = 50;
while (!ismouseclick(WM_LBUTTONDOWN))
delay(DELAY);
}
void menu(){
float num1,num2,resultado;
int operacion;
int respuesta;
system ("color 08");
do{
system("cls");
printf("\t Calculadora \n");
printf("Por favor, selecciona una opción \n");
printf(" 1: Suma \n 2: Resta \n 3: División \n 4: Producto \n");
scanf("%d",&operacion);
switch (operacion)
{
case 1:
printf("SUMA \n");
printf("Introduce el primer número, por favor:
...