Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > IT форум > Помощь студентам
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 26.04.2013, 22:15   #1
NikolVladi
Новичок
Джуниор
 
Регистрация: 26.04.2013
Сообщений: 2
По умолчанию Блок схема для программы на срр

Всем привет! Ребят, помогите, пожалуйста, нарисовать блок-схему для программы на си++ Очень нужно, завтра уже защита, а программу только сегодня дописали, и со схемами "туго". Буду очень благодарна!
Вот код:
#include <iostream>
#include <math.h>
#include <graphics.h>
#define pi 3.14159265
using namespace std;
int main()
{
int flag=0,fl,n,k1,k2,k3,k4,ax=30,ay=12 5,bx,by,cx,cy,dx,dy,px,py,AB,BC,CD, P,q,alpha,Q,min,koef,z,k,minf,f1,f2 ,f3,f4,koeff;
double Mp,Mq,alphar,x,y,yy,xx,M,Px,Py,m;
cout <<"Welcome to the program for the calculation and distribution of forces in the static model. Press Enter to continue.";
getchar();
cout <<"\n\nPlease, enter the linear dimensions (they should be positive), the modules of operating forces and the angle for P force.";

do{
do{cout <<"\n\nAB=";
cin >>AB;
if(AB<0)
{cout <<"\nIt should be positive,enter it again please\n";
}} while(AB<0);
do{cout <<"\nBC=";
cin >>BC;
if(BC<0)
{cout <<"\nIt should be positive,enter it again please\n";
}} while(BC<0);
do{cout <<"\nCD=";
cin >>CD;
if(CD<0)
{cout <<"\nIt should be positive,enter it again please\n";
}} while(CD<0);
do{cout <<"\nP=";
cin >>P;
if(P<0)
{cout <<"\nIt should be positive,enter it again please\n";
}} while(P<0);
do{cout <<"\nq=";
cin >>q;
if(q<0)
{cout <<"\nIt should be positive,enter it again please\n";
}} while(q<0);
cout <<"\nalpha=";
cin >>alpha;
if(alpha>360)
{n=alpha/360;
alpha=alpha-n*360;
cout <<"\nThe angle should be less than 360 degrees. Removing the number of full turns, we get the angle "<<alpha;}
cout <<"\nDo you want to change entered data? Yes-1, no-0\n";
cin >>flag;
}
while (flag!=0);
alphar=alpha*pi/180;
Mp=P*AB*sin(alphar);
Mq=q*BC*BC/2;
Px=-P*cos(alphar);
Py=P*sin(alphar);
M=Mp+Mq;
m=-M;
Q=q*BC;
x=P*cos(alphar)-Q;
y=-P*sin(alphar);
cout<<"\nYou entered:";
printf("\n|------|------|------|------|------|------|");
printf("\n| AB | BC | CD | P | q | alpha|");
printf("\n|------|------|------|------|------|------|");
printf("\n|%6d|%6d|%6d|%6d|%6d|%6d| ",AB,BC,CD,P,q,alpha);
printf("\n|------|------|------|------|------|------|");
cout<<"\n\nThe calculation will be based on formulas";
cout<<"\nQ=q*BC";
cout<<"\nMp=P*AB*sin(alpha)";
cout<<"\nMq=Q*BC/2";
cout<<"\n\nForm a table of results using calculated data";
printf("\n|------|-----------|---------|---------|--------|--------|");
printf("\n| | M | P | Q | X | Y |");
printf("\n|------|-----------|---------|---------|--------|--------|");
printf("\n| X | 0|%9.2lf|%9d|%8.2lf| 0|",Px,Q,x);
printf("\n|------|-----------|---------|---------|--------|--------|");
printf("\n| Y | 0|%9.2lf| 0| 0|%8.2lf|",Py,y);
printf("\n|------|-----------|---------|---------|--------|--------|");
printf("\n| M |%11.2lf|%9.2lf|%9.0lf| 0| 0|",m,Mp,Mq);
printf("\n|------|-----------|---------|---------|--------|--------|");
cout<<"\n\nSet up a system of equations describing the system in balance based on the table of results";
cout<<"\nX-P*cos(alpha)=0";
cout<<"\nY+P*sin(alpha)=0";
cout<<"\nP*AB*sin(alpha)+Q*BC/2-M=0";
cout<<"\n\nYou can see graphic forces in the picture";
min=AB;
if (min>BC)
{min=BC;}
if(min>CD)
{min=CD;}
k1=AB/min; k2=BC/min; k3=CD/min;
koef=260/(k2+k3);
if(k1*koef>350)
{koef=koef/2;}
AB=k1*koef; BC=k2*koef; CD=k3*koef;
NikolVladi вне форума Ответить с цитированием
Старый 26.04.2013, 22:16   #2
NikolVladi
Новичок
Джуниор
 
Регистрация: 26.04.2013
Сообщений: 2
По умолчанию

Продолжение:

if(fabs(x)/abs(P)>100&&fabs(x)/fabs(y)>100&&fabs(x)/abs(q)>100)
{x=x/100; printf("\nVector X is too much, so it was reduced by 100 times");}
if(fabs(x)/abs(P)>10&&fabs(x)/fabs(y)>10&&fabs(x)/abs(q)>10)
{x=x/10; printf("\nVector X is too much, so it was reduced by 10 times");}
if(fabs(y)/abs(P)>10&&fabs(y)/fabs(x)>10&&fabs(y)/abs(q)>10)
{y=y/10; printf("\nVector Y is too much, so it was reduced by 10 times");}
if(abs(P)/fabs(y)>10&&abs(P)/fabs(x)>10&&abs(P)/abs(q)>10)
{P=P/10; printf("\nVector P is too much, so it was reduced by 10 times");}
if(abs(q)/fabs(y)>10&&abs(q)/abs(P)>10&&abs(q)/fabs(x)>10)
{q=q/10; printf("\nVector Q is too much, so it was reduced by 10 times");}
do{
P=P/2;q=q/2;x=x/2;y=y/2;
}while(fabs(x)>30&&P>125&&q>bx-ax&&fabs(y)>125);
initwindow(400,400);
setcolor(0);
setbkcolor(15);
bar(0,0,400,400);
moveto(30,100);
lineto(30,150);
moveto(25,125);
lineto(30+AB,125); //AB
outtextxy(ax+5,ay+5,"A");
by=125; bx=getx();
lineto(bx,125+BC); //BC
outtextxy(bx+5,by,"B");
cx=bx; cy=gety();
outtextxy(cx+5,cy,"C");
lineto(cx,cy+CD); //CD
dx=cx; dy=gety();
outtextxy(dx+5,dy-10,"D");
ellipse((AB+30)/2,ay,60,300,5,10);
setfillstyle(1,0);
fillellipse(ax,ay,2,2);
fillellipse(bx,by,2,2);
fillellipse(cx,cy,2,2);
fillellipse(dx,dy,2,2);
setcolor(COLOR(255,0,0));
setlinestyle(0,0,3);

if(y<0){y=-y;yy=ay+y;}
else{yy=ay-y;}

xx=ax+x;
moveto(ax,ay); lineto(ax,yy);
outtextxy(ax-15,yy-5,"Y");
moveto(ax,ay); lineto(xx,ay);
outtextxy(xx+5,ay-20,"X");
setcolor(COLOR(0,0,255));
k=1;z=1;
if(alphar>=0&&alphar<=90){k=-1;z=-1;}
else{if(alphar>90&&alphar<=180){k=1 ;z=-1;}
else{if(alphar>=270&&alphar<=360){k =-1;}
}
}
px=bx-P*cos(alphar);
py=by-P*sin(alphar);
outtextxy(px-10,py-10,"P");
moveto(bx,by);lineto(px,py);
arc(bx,by,180-alpha,180,10);
moveto(bx-q,by);lineto(bx-q,by+BC);
lineto(cx,by+BC);moveto(bx-q,by+3*BC/4);
lineto(cx,by+3*BC/4);moveto(bx-q,by+BC/2);
lineto(cx,by+BC/2);moveto(bx-q,by+BC/4);
lineto(cx,by+BC/4);
outtextxy(bx-q-10,by+BC/2,"q");
while(!kbhit());
closegraph();

getchar();
return 0;
}
NikolVladi вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Нужна блок-схема для программы Destox Паскаль, Turbo Pascal, PascalABC.NET 0 28.03.2013 19:06
блок-схема для программы в паскале 4еловек-молекула Помощь студентам 2 16.12.2012 17:08
Блок-схема для программы TVIST95 Помощь студентам 0 05.11.2012 23:23
Блок схема для программы Bloodnes Помощь студентам 6 13.01.2011 17:26