C: Grafica in C - aplicatii rezolvate


1) Să se deseneze un dreptunghi umplut (rezolvare...)

2) Să se deseneze un dreptunghi neumplut (rezolvare...)

3) Să se deseneze un cerc (rezolvare...)

4) Să se deseneze cercuri concentrice (rezolvare...)

5) Să se deseneze un dreptunghi cu coltul stanga-sus, in coltul din stanga-sus a ecranului (rezolvare...)

6) Să se deseneze un dreptunghi cu coltul stanga-sus, in coltul din stanga-sus a ecranului. Lungimea si latimea sa se introduca de la tastatura (rezolvare...)

7) Să se deseneze un dreptunghi cu coltul stanga-jos, in coltul din stanga-jos a ecranului. Lungimea si latimea sa se introduca de la tastatura (rezolvare...)

8) Să se deseneze un dreptunghi cu toate laturile introduse de la tastatura (rezolvare...)

9) Să se deseneze un cerc cu abscisa, ordonata si raza cercului introduse de la tastatura (rezolvare...)

10) Sa se deseneze n cercuri. Abscisele, ordonatele si razele se dau de la tastatura. Desenarea se va efectua doar daca cercul este in intregime in spatiul ecran (rezolvare...)

11) Sa se deseneze o elipsa (rezolvare...)

12) Sa se deseneze o elipsa cu toate datele introduse de la tastatura (rezolvare...)

13) Sa se deseneze o elipsa care are centrul in centrul ecranului si are toate datele introduse de la tastatura. Desenarea se va face doar in situatia in care desenul se incadreaza in spatiul de ecran (rezolvare...)

Rezolvari

#include <graphics.h>
int main( )
{
    initwindow(600, 600, "Dreptunghi");
    bar(500, 500, 100, 100); 
    while (!kbhit( ))
    {
        delay(200);
    }
    return 0;
}


#include <graphics.h>
int main( )
{
    initwindow(600, 600, " Dreptunghi");
    rectangle(50,275,150,400);
    setcolor (15);
    while (!kbhit( ))
    {
        delay(200);
    }
    return 0;
}


#include <graphics.h>
int main( )
{
    initwindow(400, 300, "Cerc");
    circle(100, 50, 40);
    while (!kbhit( ))
    {
        delay(200);
    }
    return 0;
}


#include <graphics.h>
 
int main()
{ 
   int gd = DETECT, gm;
   int x = 320, y = 240, radius;
 
   initgraph(&gd, &gm, "C:\\TC\\BGI");
 
   for ( radius = 25; radius <= 125 ; radius = radius + 20)
      circle(x, y, radius);
 
   getch();
   closegraph();
   return 0;
}


#include <graphics.h>
int main( )
{
    initwindow(600, 600, " Dreptunghi");
    rectangle(0,0,20,50);
 
    while (!kbhit( ))
    {
        delay(200);
    }
    return 0;
}


#include <graphics.h> 	// biblioteca primitive grafice
#include <stdlib.h>
int main()
{ 
    
   int graphdriver, graphmode;
   int left,top,right,bottom;
   graphdriver = DETECT;
   initgraph(&graphdriver, &graphmode, " ");
   left=top=0;   
   printf("Introduceti right: ", right);
   scanf("%d", &right);
   printf("Introduceti bottom: ", bottom);
   scanf("%d", &bottom);
   rectangle(left,top,right,bottom);
   getch();
   closegraph();
   return 0;
}


#include <graphics.h> 	// biblioteca primitive grafice
#include <stdlib.h>
#include <dos.h>
#include <conio.h> 
int main()
{ 
    int graphdriver, graphmode;
    int x,y;
    
   graphdriver = DETECT;
 
   initgraph(&graphdriver, &graphmode, " ");
   
   printf("Introduceti lungimea dreptunghiului: ", x);
   scanf("%d", &x);
   
   printf("Introduceti latimea dreptunghiului: ", y);
   scanf("%d", &y);
   //initwindow(900, 900, "Dreptunghi");
   rectangle(0,0,x,y);
 
   getch();
   closegraph();
   return 0;
}
 
SAU
 
#include <graphics.h> 	// biblioteca primitive grafice
#include <stdlib.h> 
int main()
{ 
   int graphdriver, graphmode;
   int left,top,right,bottom;
   graphdriver = DETECT;
   initgraph(&graphdriver, &graphmode, " ");
   left=0;
   bottom=getmaxy();
   printf("Introduceti right: ", right);
   scanf("%d", &right);
   printf("Introduceti bottom: ", top);
   scanf("%d", &top);
   rectangle(left,top,right,bottom);
   getch();
   closegraph();
   return 0;
}


#include <graphics.h>	 // biblioteca primitive grafice
#include <stdlib.h> 
int main()
{ 
   int graphdriver, graphmode;
   int left,top,right,bottom; 
   graphdriver = DETECT;
   initgraph(&graphdriver, &graphmode, " ");
   printf("Introduceti left: ", left);
   scanf("%d", &left);
   printf("Introduceti top: ", top);
   scanf("%d", &top);  
   printf("Introduceti right: ", right);
   scanf("%d", &right);
   printf("Introduceti bottom: ", bottom);
   scanf("%d", &bottom);
   rectangle(left,top,right,bottom);
   getch();
   closegraph();
   return 0;
}


#include <graphics.h> 	// biblioteca primitive grafice
#include <stdlib.h>
int main()
{ 
   int graphdriver, graphmode;
   int x,y,radius;
   graphdriver = DETECT;
   initgraph(&graphdriver, &graphmode, " ");
   printf("Introduceti x: ", x);
   scanf("%d", &x);
   printf("Introduceti y: ", y);
   scanf("%d", &y);
   printf("Introduceti radius: ", radius);
   scanf("%d", &radius);
   circle(x,y,radius);
   getch();
   closegraph();
   return 0;
}


#include "graphics.h"
#include "conio.h"
#include "stdlib.h" 
int main()
{ 
   int graphdriver, graphmode;
   int x[30],y[30],radius[30];
   int n;  
   graphdriver = DETECT;
   initgraph(&graphdriver, &graphmode, " ");
   printf("Introduceti nr de cercuri: ");
   scanf("%d", &n);
   for (int i=0; i<n; i++)
   {
       printf("Cercul %d: ",i+1);
       printf("Introduceti x: ");
       scanf("%d", &x[i]);
       printf("Introduceti y: ");
       scanf("%d", &y[i]);
       printf("Introduceti raza: ");
       scanf("%d", &radius[i]);
   }
    
   for (int i=0; i<n; i++)
   if(x[i]>0 && x[i]<getmaxx() && y[i]>0 && y[i]<getmaxy() && (x[i]+radius[i])<getmaxx() && 
   (x[i]>radius[i]) && (y[i]+radius[i])<getmaxy() && (y[i]>radius[i]))
   circle(x[i],y[i],radius[i]);
   getch();
   closegraph();
   return 0;
}


#include <graphics.h> // biblioteca primitive grafice
#include <stdlib.h>
int main()
{ 
   int graphdriver, graphmode;
   int x, y, stangle, endangle, xradius, yradius;
   int n;
   graphdriver = DETECT;
   initgraph(&graphdriver, &graphmode, " ");
   ellipse(500, 100,0,360, 100,50);
   getch();
   closegraph();
   return 0;
}


#include <graphics.h> 	// biblioteca primitive grafice
#include <stdlib.h>
int main()
{ 
   int graphdriver, graphmode;
   int x, y, stangle, endangle, xradius, yradius;
   graphdriver = DETECT;
   initgraph(&graphdriver, &graphmode, " ");
   printf("Introduceti x: ");
   scanf("%d", &x);
      printf("Introduceti y: ");
   scanf("%d", &y);
      printf("Introduceti stangle: ");
   scanf("%d", &stangle);
      printf("Introduceti endangle: ");
   scanf("%d", &endangle);
      printf("Introduceti xradius: ");
   scanf("%d", &xradius);
      printf("Introduceti yradius: ");
   scanf("%d", &yradius);
   ellipse(x, y, stangle, endangle, xradius, yradius);
   getch();
   closegraph();
   return 0;
}


#include <graphics.h> // biblioteca primitive grafice
#include <stdlib.h>
int main()
{ 
   int graphdriver, graphmode;
   int x, y, stangle, endangle, xradius, yradius;
   graphdriver = DETECT;
   initgraph(&graphdriver, &graphmode, " ");
   x=getmaxx()/2;
   y=getmaxy()/2;
      printf("Introduceti stangle: ");
   scanf("%d", &stangle);
      printf("Introduceti endangle: ");
   scanf("%d", &endangle);
      printf("Introduceti xradius: ");
   scanf("%d", &xradius);
      printf("Introduceti yradius: ");
   scanf("%d", &yradius);
   if ( (xradius<getmaxy()/2) && (yradius<getmaxx()/2) )
   {
    ellipse(x, y, 0, 350, xradius, yradius);
    getch();
    closegraph();
   }
   else
   {
	closegraph();
	printf("\n\nELIPSA NU POATE FI DESENATA IN SPATIUL ECRAN.\n");
	getch();
   }
}
COMENTARII

optional (nu va fi afisat pe website)
max: 255 caractere


Acest site utilizeaza cookie-uri. Navigand in continuare va exprimati acordul asupra folosirii cookie-urilor.