Escolar Documentos
Profissional Documentos
Cultura Documentos
5
Problema 1 macrouri
#include<stdio.h>
#include<conio.h>
enum boolean {false, true};
#define MAXIM(x,y) (x)>(y) ?(x):(y)
#define MINIM(x,y) (x)<(y) ?(x):(y)
#define EGAL(x,y) (x)==(y)?true:false
void main(void){
int a,b;
int m;
clrscr();
scanf("a=%d b=%d", &a, &b);
m = MAXIM(a,b);
printf("\nMaximul este:%d",m);
m = MINIM(a,b);
printf("\nMinimul este:%d",m);
puts("\nTestarea egalitatii:");
if(EGAL(a,b))
puts("Sunt egale!");
else
puts("Nu sunt egale!");
getch();
}
};
void main(void) {
_setcursortype(_NOCURSOR);
clrscr();
fereastra(1,1,79,25,'s');
fereastra(10,10, 40, 20,'d');
getch();
_setcursortype(_NORMALCURSOR);
clrscr();
}
ESC 0x1b
SAGEATA_STANGA 0x4B
SAGEATA_SUS 0x48
SAGEATA_DREAPTA 0x4D
SAGEATA_JOS 0x50
PAS 1
void main(void) {
_setcursortype(_NOCURSOR);
int x1, y1, x2, y2;
clrscr();
//parametrii ecranului
struct text_info parecr;
gettextinfo(&parecr);
printf("\ninaltimea ecranului: %d latimea ecranului %d",
parecr.screenheight, parecr.screenwidth);
printf("\nx1="); scanf("%d", &x1);
printf("\ny1="); scanf("%d", &y1);
printf("\nx2="); scanf("%d", &x2);
printf("\ny2="); scanf("%d", &y2);
fflush(stdin);
desen(x1, y1, x2, y2);
gotoxy(30,25);
cprintf("S-a apasat tasta ESC");
getch();
clrscr();
_setcursortype(_NORMALCURSOR);
}
void mutaStanga(int& x1, int y1, int& x2, int y2) {
if(x1-PAS >=1) {
x1 -=PAS;
x2 -=PAS;
clrscr();
dreptunghiSimplu(x1,y1,x2, y2);
}
}
void mutaSus(int x1, int& y1, int x2, int& y2) {
if(y1-PAS >=1) {
y1 -=PAS;
y2 -=PAS;
clrscr();
dreptunghiSimplu(x1,y1,x2, y2);
}
}
void mutaDreapta(int& x1, int y1, int&x2, int y2) {
if(x2+PAS <= 80) {
x1 += PAS;
x2 += PAS;
clrscr();
dreptunghiSimplu(x1,y1,x2,y2);
}
}
void mutaJos(int x1, int& y1, int x2, int& y2) {
if(y2 + PAS < 25) {
y1 +=PAS;
y2 +=PAS;
clrscr();
dreptunghiSimplu(x1,y1,x2, y2);
}
}
void desen(int& x1, int& y1, int& x2, int& y2) {
char c;
dreptunghiSimplu(x1, y1, x2, y2);
do {
c = getch();
if(c==0x00)
c=getch();
switch(c){
case SAGEATA_STANGA:
mutaStanga(x1, y1, x2, y2);
break;
case SAGEATA_DREAPTA:
mutaDreapta(x1,y1,x2,y2);
break;
case SAGEATA_SUS:
mutaSus(x1,y1,x2,y2);
break;
case SAGEATA_JOS:
mutaJos(x1,y1,x2,y2);
break;
default: fflush(stdin);
};
}while(c != ESC);