на главную


Правила общения на форуме


[SAPA2]



 
Остатки Разума -> СТИРАТЬ НЕЛЬЗЯ ОСТАВИТЬ(Поставьте запятую сами) - squaresintl.com

sjai

пишет 10 июн 2007 в 1:01

#include <cstdlib>
#include <iostream>
#include <stdio.h>
#include <conio.h>
#include <math.h>
#include <graphics.h>
#include <stdlib.h>

#define pi 3.141592
#define N 11
#define M 300
#define tn 0
#define tk 2*pi
using namespace std;

int i, k, n=11;
float UN=50.0, Uin1=10.0, Uin2=50.0, b1=10.0, b2=10.0, b3=60.0;
float a=0.5, a1=0.5, a2=0.5, a3=0.5;
float W;

float dtiUvh(int n, float *arr, float *arr1)
{
float dt;
dt=fabs(tk-tn)/(n-1);
for(i=0;i<n;i++)
{
arr[i]=tn+i*dt;
arr1[i]=UN*exp(-a*arr[i])*sin(arr[i]);
}
return(arr[i],arr1[i]);
}

float Uvyh(int n, float *arr1, float *arr2)
{
for(i=0;i<n;i++)
{
if(arr1[i]<=Uin1) arr2[i]=a1*arr1[i]+b1;
if(Uin1<arr1[i] && arr1[i]<=Uin2) arr2[i]=a2*arr1[i]+b2;
if(arr1[i]>Uin2) arr2[i]=a3*arr1[i]+b3;
}
return(arr2[i]);
}
void zapisj(float *arr, float *arr1, float *arr2)
{
FILE *f; FILE *g; FILE *h;
f=fopen("t.txt","w");
g=fopen("Uin.txt","w");
h=fopen("Uout.txt","w");
if(f==NULL)
{printf("\n ERROR!");
exit(1);} else
{
for(i=0;i<n;i++){
fprintf(f,"\n %.3f",arr[i]);
fprintf(g,"\n %.3f",arr1[i]);
fprintf(h,"\n %.3f",arr2[i]);}
fclose(f);
fclose(g);
fclose(h);}
return;
}



float raznoctb(int n,float Uout[])
{
int i;
float max,min,h,w;
max=Uout[0];
for(i=1;i<n;i++)
{
if(Uout[i]>max)
{
max=Uout[i];
}
}
min=Uout[0];
for(i=1;i<n;i++)
{
if(Uout[i]<min)
{
min=Uout[i];

}

}
h=max-min;
return (h);

}

void gra(float *U, int x1, int x2, int y1, int y2, int n)
{
int x, y;
int i;
float Umax, Umin;
Umin=U[0];
Umax=U[0];
for(i=1;i<n;i++)
{
if(U[i]<Umin)
Umin=U[i];
}
for(i=1;i<M;i++)
{
if(U[i]>Umax)
Umax=U[i];
}
x=x1;
y=y2-(y2-y1)*int((U[0]-Umin)/(Umax-Umin));
moveto(x,y);
for(i=1;i<n;i++)
{
x=x1+int((x2-x1)/(n-1)*i);
y=y2-int((y2-y1)/(Umax-Umin)*(U[i]-Umin));
lineto(x,y);
}
return;
}
void grafik()
{
float Uin[M], Uout[M], t[M], dt;
int x11=0, x12=319, x21=320, x22=639, y11=0, y12=239, y21=240, y22=479, gd, gm;
gd=DETECT;
dt=fabs(tk-tn)/(M-1);
for(i=0;i<M;i++)
{
t[i]=tn+i*dt;
Uin[i]=UN*exp(-a*t[i])*sin(t[i]);
if(Uin[i]<=Uin1) Uout[i]=a1*Uin[i]+b1;
if(Uin1<Uin[i] && Uin[i]<=Uin2) Uout[i]=a2*Uin[i]+b2;
if(Uin[i]>Uin2) Uout[i]=a3*Uin[i]+b3;
}
initgraph(&gd,&gm,"");
setcolor(WHITE);
setfillstyle(7,RED);
bar(1,1,320,240);
bar(320,240,640,480);
line(0,239,639,239);
line(319,0,319,479);
outtextxy(150,250,"y=Uin(t)");
outtextxy(450,220,"y=Uout(t)");
outtextxy(1,5,"y");

deizi_sweet

пишет 10 июн 2007 в 1:02

outtextxy(319,245,"y");
line(0,0,0,239);
line(0,119,318,119);
line(319,359,639,359);
outtextxy(630,349,"x");
outtextxy(300,110,"x");
outtextxy(1,125,"0");
outtextxy(319,365,"0");
gra(&Uin[0],x11,x12,y11,y12,M);
gra(&Uout[0],x21,x22,y21,y22,M);
getch();
return;
}

void otpechatj(float *arr1, float *arr2, float h, float v, float P, int n)
{
if(k=1)
{
printf("\n#######################################");
for(i=0;i<n;i++)
printf("\n %3d,%8.3f,%8.3f",i,arr1[i],arr2[i]);
printf("\n h=%f \n V=%f \n p=%f \n n=%d",h,v,P,n);
printf("\n#######################################");
}
return;
}

int main()
{ int gd, gm;

float Uin[500], Uout[500], t[500], dt, V=10000000.0, p, h;
float *arr, *arr1, *arr2;
float E=0.12;
int J, Jm=10;
V=pow(10,37);
arr=&arr[0];
arr1=&arr1[0];
arr2=&arr2[0];
for(J=1;J<=Jm;J++)
{
dtiUvh(n,t,Uin);
Uvyh(n,Uin,Uout);
h=raznoctb(n,Uout);
W=h;
p=fabs(W-V);
otpechatj(Uin,Uout,W,V,p,n);

printf("\n t %p",&arr);
printf("\n Uin %p",&arr1);
printf("\n Uout %p\n",&arr2);

if(p<E)
{

printf("\n BALLl OTVET h=%.3f",h);
break;
}
else
{
n=2*n;
V=W;
}
}
if(p>E)
printf("Tochnostj ne dostignuta!");
zapisj(t,Uin,Uout);
grafik();
getche();
closegraph();


system("PAUSE");
return EXIT_SUCCESS;
}

aminych2007

пишет 13 июн 2007 в 15:08

А тоже самое в двоичной системе слабо?

elena_karenina

пишет 21 июн 2007 в 10:38

Хоть в троичной

muhumandorik

пишет 26 июн 2007 в 18:21

жги балолаечник!

dsmit95

пишет 20 июл 2007 в 0:44

http://mega-pricol.narod.ru кульные приколы, посмейтесь... =)))


   

Кто онлайн

Сейчас просматривают форум: Yahoo [Bot] и 7 гостей


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum


Search for:
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware.
[ Time : 0.083s | 11 Queries | GZIP : Off ]