Я делал задачу в которой требовалось создать оконно-текстовы интрефейс с помощью графики...но под конец возникли проблемы:
Код:
#include <conio.h>
#include <stdlib.h>
#include <iostream.h>
#include <stdio.h>
#include <math.h>
#include <graphics.h>
float fiz(float a,float b,float rad)
{float f;
f=8987742438*(a*b)/(rad*rad);
return f;}
float prog(float per,float krok,float kilk)
{float k=per;int i;
for (i=1;i==kilk;i++)
{k=k*(per+(kilk-1)*krok);}
return k;}
float kon(float rad,float tvir)
{float p;
p=3.141596*rad*tvir+3.141596*rad*rad;
return p;}
void window(int x,int y)
{clrscr();
setfillstyle(SOLID_FILL,BLUE);
bar(x-180,y+40,x+180,y-40);}
void text(int x,int y)
{outtextxy(x-180,y-30,"1)Sula Kylona");
outtextxy(x-180,y-10,"2)Dobutok chleniv arufmetuchnoyi progresii");
outtextxy(x-180,y+10,"3)Ploshya konusa");
outtextxy(x-180,y+30,"4)Vuhid");}
void choice(int napr,int x,int y)
{int posit1,posit2;
clearscr();
window(x,y);
switch(napr){
case 1:{posit1=-40;posit2=-20;}
case 2:{posit1=-20;posit2=0;}
case 3:{posit1=0;posit2=20;}
case 4:{posit1=20;posit2=40;}}
setfillstyle(SOLID_FILL,GREEN);
bar(x-180,y+posit2,x+180,y+posit1);
text(x,y);}
float a1,d,n,r,l,R,q1,q2,F,P,S;int gdriver = DETECT, gmode, errorcode;
int midx,midy,k,pos=4;char c;
void main(void)
{clrscr();
initgraph(&gdriver,&gmode,"q:\\tc\\bgi\\");
midx=getmaxx()/2;
midy=getmaxy()/2;
m:window(midx,midy);
setfillstyle(SOLID_FILL,GREEN);
bar(midx-180,midy+40,midx+180,midy+20);
text(midx,midy);
ch:c=getch();k=c;
if (k==56) {if (pos==1) {pos=4;goto m;} else {pos--;
choice(pos,midx,midy);};goto ch;};
if (k==50) {if (pos==4) {pos=1;window(midx,midy);
setfillstyle(SOLID_FILL,GREEN);
bar(midx-180,midy-40,midx+180,midy-20);text(midx,midy);
goto ch;}
else {choice(pos,midx,midy);pos++;goto ch;};};
if (k==13) {switch(pos)
{case 1:{clrscr();
printf("Vvedit 2 zaryadu i vidstan mizh numu\n");
scanf("%f",&q1);scanf("%f",&q2);scanf("%f",&R);
F=fiz(q1,q2,R);printf("Sula rivna %0.3f H\n",F);
getch();pos=4;goto m;}
case 2:{clrscr();
printf("Vvedit a1,d,n\n");
scanf("%f",&a1);scanf("%f",&d);scanf("%f",&n);
P=prog(a1,d,n);
printf("Dobutok: %0.3f\n",P);
getch();pos=4;goto m;}
case 3:{clrscr();
printf("Vvedit tvirnu ta radius conusa\n");
scanf("%f",&l);scanf("%f",&r);
S=kon(r,l);
printf("S=%0.3f\n",S);
getch();pos=4;goto m;}
case 4:{goto ex;}}};
getch();
ex:closegraph();
}