#include
#include
#include
#include
#include #include
#define CLIP_ON 1
#define FON_2 CYAN
#define FON_1 7
#define COL_1 60
#define COL_2 57
#define COL_3 58

void Titul (void);
void GRAF(float E, float C, float r1,float r2);
void SHEMA(void);

int main(void)
{
clrscr();
Titul ();
clrscr();
int gdriver = DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, «c:\\bcpp\\bgi»);
errorcode = graphresult();
if (errorcode != grOk)
{
printf(«Graphics error: %s\n», grapherrormsg(errorcode));
printf(«Press any key to halt:»);
getch();
exit(1);
}
///——————————

float E;
float t;
float C;
float r1;
float r2;

E=100;
C=1e-03;
r1=3000;
r2=1000;

SHEMA(); GRAF(E, C, r1,r2);
//………………………………
char ch;
while(ch!=27)
{
restorecrtmode();
clrscr(); //
//textbackground(YELLOW);
textcolor(57);
printf(«\n\n\n\n\n\n\n\n»);
cprintf(» EIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII»»); printf(«\n»);
cprintf(» ?„«i c?a®¤a § ?a®Fa ¬?  a?aiai: ‘e’ ?»); printf(«\n»);
cprintf(» ? ?»); printf(«\n»);
cprintf(» ?„«i ?a®¤®c¦Yi ?a®Fa ¬? § ®c?¬? § cYi¬? ?»); printf(«\n»);
cprintf(» ? ? a ¬Yaaic aaY¬?,  a?aiai: ‘n’ ?»); printf(«\n»);
cprintf(» EIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII1/4″); printf(«\n»);

ch=getch();
switch(ch)
{
case ‘e’: exit(1); break;
case ‘n’:
clrscr(); textcolor(GREEN);
cprintf(» UAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAe?»); printf(«\n»);
cprintf(» ? „«i c¤ «®F® ci¤®!a ¦Yi ?a®aeYaic Y®!ai¤®, e®!: ?»); printf(«\n»);
cprintf(» AAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAe?»); printf(«\n»);
cprintf(» ? E<=100 B ?"); printf("\n"); cprintf(" ? C=(0,5..3) ¬?” ?"); printf("\n"); cprintf(" ? r1=(500..3000) ?¬ ?"); printf("\n"); cprintf(" ? r2=(500..3000) ?¬ ?"); printf("\n"); cprintf(" AAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeAeU"); printf("\n"); textcolor(WHITE); cprintf("\n\n‚cY¤iai ®ci § cYi E (B) = "); scanf("%f",&E); cprintf("\n‚cY¤iai ®ci § cYi C (¬?”) = "); scanf("%f",&C); cprintf("\n‚cY¤iai ®ci § cYi r1 (?¬) = "); scanf("%f",&r1); cprintf("\n‚cY¤iai ®ci § cYi r2 (?¬) = "); scanf("%f",&r2); setgraphmode(getgraphmode()); SHEMA(); GRAF(E, C*pow10(-3), r1,r2); break; default: { clrscr(); //textbackground(7); textcolor(RED+BLINK); printf("\n\n\n\n\n\n\n\n\n\n\t\t"); cprintf(" „?ciaiai e®  a?a? iaY"); delay(4000);textcolor(WHITE);restorecrtmode();clrscr(); } } } restorecrtmode(); ///------------------------------ getch(); closegraph(); clrscr(); return 0; } //////~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /////|||||||||||||||||||||||||||||| void SHEMA(void) { ////------------------ ?i¤F®a®c«io¬® Fa ae ci?® cleardevice(); int y0_port1,y1_port1; y0_port1=0; y1_port1=0.4*getmaxy(); setviewport(0,y0_port1,getmaxx(),y1_port1, CLIP_ON); setfillstyle(SOLID_FILL, FON_1); //§ ?®cYi ?®«i®a®¬ floodfill(5, 5, 13); // aY¦ a ¬Y rectangle(0,0,getmaxx(),y1_port1-y0_port1); /////////------------------------------------------------- int x1=0.25*getmaxx(), x1a, y1=40, y1a=30; int x3=0.75*getmaxx(), y3=y1_port1-30, x3a=20, r=3, x3b; int x2=0.5*getmaxx(), y2=(y1+y3)/2; int R=15, l=8; //a ¤iaa ¤¦YaY«  Y.a.a. i ¤®c¦?  aaai«?? int dC=4, lC=14; //a®ce?  i e?a?  ?®¤Ya a®a  int hr=8,lr=56; // e?a?  a  ¤®c¦?  aY§?aa®a  x1a=(x2-x1-lr)/2; circle(x2,y1,2); circle(x2,y3,2); setfillstyle(SOLID_FILL,WHITE); floodfill(x2,y1-1,WHITE); floodfill(x2,y3-1,WHITE); line(x1,y1,x1+x1a,y1); setfillstyle(1, WHITE); bar(x1+x1a,y1-hr,x1+x1a+lr,y1+hr); line(x1+x1a+lr,y1,x3,y1); line(x3,y1,x3,y1+y1a); bar(x3-hr,y1+y1a,x3+hr,y1+y1a+lr); line(x3,y1+y1a,x3,y3); line(x3,y3,(x3+x2)/2+x3a+r,y3); circle((x3+x2)/2+x3a,y3,r); line(x1,y3,(x3+x2)/2-x3a-r,y3); circle((x3+x2)/2-x3a,y3,r); int lk=37; //?«ic line((x3+x2)/2-x3a+r*0.87,y3-r*0.5,(x3+x2)/2-x3a+lk*0.87,y3-lk*0.5);//?«ic circle(x1,y2,R); line(x1,y1,x1,y2-R); line(x1,y3,x1,y2+R); line(x1,y2+l,x1,y2-l); line(x1,y2-l,x1-2,y2-l+6); line(x1,y2-l,x1+2,y2-l+6); line(x2-lC,y2-dC,x2+lC,y2-dC); line(x2-lC,y2+dC,x2+lC,y2+dC); line(x2,y1,x2,y2-dC); line(x2,y3,x2,y2+dC); //?i¤??aai¬® Y«Y¬Ya? setcolor(GREEN); settextstyle(3, HORIZ_DIR, 1); outtextxy(x1+22,y2-14,"E"); outtextxy((x1+x2)/2-8,y1-32,"r1"); outtextxy(x2-32,y2-10,"C"); outtextxy(x3-30,y2-12,"r2"); outtextxy((x2+x3)/2,y3,"K"); } //////-------------- void GRAF(float E, float C, float r1,float r2) { ////------------------ ?i¤F®a®c«io¬® Fa ae ci?® #2 //setbkcolor(7); setcolor(WHITE); settextstyle(0,0,1); float y0_port2,y1_port2; y0_port2=0.4*getmaxy(); y1_port2=getmaxy(); setviewport(0,y0_port2,getmaxx(),y1_port2, CLIP_ON); setfillstyle(SOLID_FILL, FON_2); //§ ?®cYi ?®«i®a®¬ floodfill(5, 5, 13); // aY¦ a ¬Y rectangle(0,0,getmaxx(),y1_port2-y0_port2); ////--------------------------- float y0_g,x0_g; float kin=0.8*getmaxx(); //?iYaei ®ai ®a¤? a y0_g=96+(y1_port2-y0_port2)/2; // printf(" y0_g=%i ",y0_g); x0_g=150; line(x0_g-120,y0_g,kin,y0_g); //ciai ®a¤? a line(x0_g,10,x0_g,y1_port2-y0_port2-20); //ciai  !aae?a line(x0_g,10,x0_g+2,10+5); //aaai«®c?  line(x0_g,10,x0_g-2,10+5); line(kin,y0_g,kin-5,y0_g-2); line(kin,y0_g,kin-5,y0_g+2); setcolor(CGA_CYAN); settextstyle(7,0,1); outtextxy(x0_g+6,4,"Uc, V"); // setcolor(WHITE); outtextxy(kin+6,y0_g-10,"t, ms"); ///////////............................. float Uck=E*r2/(r1+r2); float t,tau,y; float mU=2, mt=1.0e-2;; //¬ aea !? ?® ®aia setcolor(COL_3); setlinestyle(8,1,1); line(x0_g-110,y0_g-E*mU,x0_g,y0_g-E*mU); moveto(x0_g,y0_g-mU*E); tau=r1*r2/(r1+r2)*C; //printf("tau=%.12f",tau); printf(" mt=%.12f",mt); for(int i=0; i

Похожие записи