,   CyberForum.ru

- C++

C++ delete ? http://www.cyberforum.ru/cpp-beginners/thread625366.html
, void *p1; void *p2; VCL- TButton, TMyClass; p1=new TButton(NULL); p2=new TMyClass(); ? .. delete p1; delete p2; delete (TButton*)p1; delete (TMyClass*)p2; RAD Studio XE Win7,...
C++ . 1.h: int* MyMin(int* p2,const int (size)) /*????*/ //int* (*MyMin) (int(*p2), int size) { //T* el = array; int min = p2; for (int i = 0; i < size; i++) { http://www.cyberforum.ru/cpp-beginners/thread625320.html
C++
n, 0 5.
C++ ASCII
"POST" Speech . ASCII. , . - , . #include <tchar.h> #include <cstdlib> #include <fstream> #include...
C++ http://www.cyberforum.ru/cpp-beginners/thread625313.html
C++ - . ?

-==-
FAQ
20.07.2012, 12:07    
akhalex
, ?
, :
printf("t=%3f val=%3.3f \n" ,t,val???);
:
t=0.000 val= 1
t=1.000 val= 0,284-0,959i
t=2.000 val= -0.839-0.544i
t=3.000 val= -0.76+0.65i
t=4.000 val=0.408+0.913i
t=5.000 val= 0.991-0.132i
.txt
16
t val.
- , .
C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include <math.h>
#include <stdio.h>
#include <conio.h>
 
typedef struct 
{
    double re;
    double im;
}complex;
 
//Ôó*êöèÿ âîçâð*ù*åò ìîäóëü êîìïëåêñ*îãî ÷èñë*
double cfabs(complex val);
//Ôó*êöèÿ óì*îæ*åò êîìïëåêñ*îå ÷èñëî 
//â *ëãåáð*è÷åñêîé ôîðìå ç*ïèñè ** âåùåñòâå**îå
complex cmult(complex val, double p);
//Ôó*êöèÿ ïðåîáð*çóåò ýêñïî*å*öè*ëü*óþ ç*ïèñü
//êîìïëåêñ* â *ëãåáð*è÷åñêóþ
//exp(j*pwr) = cos(pwr) + j*sin(pwr)
complex ExpToAlg(complex pwr);
//Ôó*êöèÿ âîçâð*ù*åò ç**÷å*èå ôó*êöèè êîìïëåêñ*îãî *ðãóìå*ò*
complex z(complex val);
//Ôó*êöèÿ ïðåîáð*çóåò êîìïëåêñ*îå ÷èñëî â ñòðîêó
char * fmt(complex val, char * str);
 
int main()
{
    //Ç*ä*ëè ì*èìóþ åäè*èöó
    complex one = {0};
    one.re = 0;
    one.im = -1;
    //val áóäåò ð**èòü ç**÷å*èå exp(j*t)
    complex val = {0};
    double t;
    double tn = 0;
    double tk = 0;
    double dt = 0;
    char str[64] = {0};//Ä****ÿ ñòðîê* áóäåò ñîäåðæ*òü â ñåáå
    //òåêñòîâêó êîìïëåêñ*
    FILE * file = NULL;//Óê*ç*òåëü ** ô*éëîâûé ïîòîê
    printf("Enter t = [tn...tk]\n");
    printf("tn = ");scanf("%lf",&tn);
    printf("tk = ");scanf("%lf",&tk);
    printf("dt = ");scanf("%lf",&dt);
    file = fopen("out.txt", "w");
    if(file == NULL)
        printf("Error create out.txt\n");
    ///Ïðè îøèáêè ñîçä**èÿ ñ*ìó ïðîãó *å ðóá*þ - ïóñòü ** ýêð** âûâîäèò
    for(t = tn; t <= tk; t += dt)
    {
        val = z(cmult(one,5*t));
        sprintf(str, "%s", fmt(val, str));
        printf("t = %.3f | val = %s\n",t, str);
        if(file)
            fprintf(file,"t = %.3f | val = %s\n",t, str);
    }       
    if(file)//Åñëè ïîòîê áûë îòêðûò 
        fclose(file);//ç*êðûâ*åì åãî
    printf("Press any key to continue\n");
    getch();
    return 0;
}
 
double cfabs(complex val)
{
    return sqrt(val.re*val.re + val.im*val.im);
}
 
complex cmult(complex val, double p)
{
    val.re *= p;
    val.im *= p;
    return val;
}
 
complex ExpToAlg(complex pwr)
{
    complex arg = {0};
    double cmod = cfabs(pwr);
    arg.re = cos(cmod);
    arg.im = sin(cmod);
    return arg;
}
 
complex z(complex val)
{
    return ExpToAlg(val);
}
 
char * fmt(complex val, char * str)
{
    if(0 <= val.re)
        sprintf(str, " %.3f", val.re);
    else
        sprintf(str, "%.3f",val.re);
    if(val.im < 0)
        sprintf(str, "%s - j*", str);
    else
        sprintf(str, "%s + j*", str);
    sprintf(str, "%s%.3f", str, fabs(val.im));
    return str;
}
out.txt
  
 : rar COMPLEX.EXE.rar (23.8 , 4 )
 : txt out.txt (216 , 5 )
 : rar COMPLEX.CPP.rar (1.0 , 5 )
 
: 10:28. GMT +3.
- , ,
-
Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
@Mail.ru