.
1 .
1) void main() () .
:
[static extern] <_> <-> (< >);
[static extern]- ;
<_> - void, (int, char, short, long, float, double, long double ..);
<-> - .
< > - . , , .
,
int print_num(i,j);
void LINE1();
void LINE2(int Len, int y, char ch);
. ;.
2) void main() ( ) :
<_> <-> (< >)
{
< >;
//return <>;
}
return <>; , , , return <>; .
3) .
. 40 , .
#include <iostream.h>
#include <conio.h>
void LINE1(); // ()
void LINE2(int Len, int y, char ch);
void main()
{
cout<<" : \n ";
LINE1(); // .
cout<<" ";
LINE1();
LINE2 (20, 5, '*');//20 5
int LEN, Y;
char Ch;
cout<<" ";
cin>>LEN>>Y;
cout<<" ";
cin>>Ch;
LINE2(LEN, Y, C);//LEN Ch Y
getch()
} // main()
// ;
void LINE1()
{
int i;
cout<<\n;
for (i=1; i<=40; i++) cout<<'*';
cout<<\n;
}
//
void LINE2(int Len, int y, char ch)
{ gotoxy(1,y);
for (int i=1; i<=Len; i++)
cout<<ch;
cout<<\n;
}
2 .
1) void main () .
:
[static extern] <_> <-> (< >)
{
< >;
//return <>;
}
2) (. ).
|
|
, () , (Len, y ch). , , (LEN, Y, C). :
* , . , char , int. , ;
* . , . LINE2(*, 5, 20), char int. LINE2 (Y, LEN, -), LEN Y -;
* . , .
. , , . , .
, , : - -. - - .
1) - , , , . . :
* ;
* , LINE2 (20, 5, '*'); Len=20, y=5 ch=*, ;
* , , , , . y (, y++), Y , . . , ;
* , - . , : LINE2 (LEN*2, Y+1, *). : LINE2 (20, 5, '*'); LINE2(LEN, Y, C); , , , , . Len. .
2) - , , , , main().
: .
. :
|
|
* - , &, , void SINCOS(float x, float eps, float &y, float &z);
* , , ;
* , , , SINCOS(, , Y, Z);
* - (, eps) ;
. (y) (Y) , y, main() - Y. y Y. , () .
. x=-0.8, -0.6, -0.4, , 0.8 :
: x, y, cos(x), z, sin(x), , , .
SINCOS, . : (x) (eps) (y z), .
void SINCOS(float x, float eps, float &y, float &z);
void main()
{
float x, sn, cs;
cout<<" x y=cos(x) Cos(Standart) z=sin(x) Sin(Standart)";
cout<<\n\n;
for (x=-0.8; x<0.805; x+=0.2)
{ SINCOS(x,1E-10, cs, sn);
printf("%5.1f %10.6f %12.6f %10.6f %12.6f\n", x, cs, cos(x), sn, sin(x));
}
getch();
}
//
void SINCOS(float x, float eps, float &y, float &z)
{ float k=1, s1=1; y=1;
do
{s1=s1*(-1)*x*x/(k*(k+1));
y+=s1;
k+=2;
}
while (fabs(v1)>eps);
k=2; s1=x; z=x;
do
{ s1=s1*(-1)*x*x/(k*(k+1));
z+=s1;
k+=2;
}
while (fabs(v1)>eps);
}