Форум программистов, компьютерный форум, киберфорум
С++ для начинающих
Войти
Регистрация
Восстановить пароль
Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.67/15: Рейтинг темы: голосов - 15, средняя оценка - 4.67
0 / 0 / 0
Регистрация: 27.05.2019
Сообщений: 2

Нахождение ошибки "использование полного имени в объявлении члена не допускается"

27.05.2019, 21:25. Показов 3083. Ответов 4
Метки нет (Все метки)

Студворк — интернет-сервис помощи студентам
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
#include "stdafx.h"
#include "pch.h"
#include <iostream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cmath>
 
using namespace std;
 
 
class Complex         // класс "Комплексное число"
{
private:
    double re, im;      // действительная и мнимая части
 
public:
    // конструкторы 
    Complex(double r = 0, double i = 0)
    {
        re = r;
        im = i;
    }
 
    Complex(const Complex &c)   // конструктор копирования
    {
        re = c.re;
        im = c.im;
    }
 
    // деструктор
    ~Complex()
    {
    }
 
    // остальные функции
 
    // Модуль комплексного числа
    double abs() const
    {
        return sqrt(re * re + im * im);
    }
    const Complex conj()
    {
        re = re;
        im = -im;
        return *this;
    }
    // оператор присваивания
    const Complex& operator = (const Complex &c)
    {
        re = c.re;
        im = c.im;
 
        return (*this);
    }
 
 
    // оператор +=
    const Complex& operator += (const Complex &c)
    {
        re += c.re;
        im += c.im;
        return *this;
    }
 
    // оператор сложения
    const Complex operator + (const Complex &c)
    {
        return Complex(re + c.re, im + c.im);
    }
 
    // оператор вычитания
    const Complex operator - (const Complex &c)
    {
        return Complex(re - c.re, im - c.im);
    }
 
    // оператор умножения
    const Complex operator * (const Complex &c)
    {
        return Complex(re * c.re - im * c.im, re * c.im + im * c.re);
    }
    const Complex operator*(const double& a)
    {
        return Complex(re*a, im*a);
    }
    const Complex operator*(double &c)
    {
        Complex fp1;
        double i, j;
        i = re * c;
        j = im * c;
        fp1 = (i, j);
        return fp1;
    }
    // оператор деления
    const Complex operator / (const Complex &c)
    {
        Complex temp;
 
        double r = c.re * c.re + c.im * c.im;
        temp.re = (re * c.re + im * c.im) / r;
        temp.im = (im * c.re - re * c.im) / r;
 
        return temp;
    }
    double Complex::Re()
    {
        return re;
    }
    double Complex::Im()
    {
        return im;
    }
 
    Complex expon(Complex c)
    {
        c.re = exp(re) * cos(im);
        c.im = exp(re) * sin(im);
        return c;
    }
 
    Complex sinus(Complex c)
    {
        c.re = sin(re) * cosh(im);
        c.im = cos(re) * sinh(im);
        return c;
    }
    Complex cosinus(Complex c)
    {
        c.re = cos(re) * cosh(im);
        c.im = -sin(re) * sinh(im);
        return c;
    }
    // укажем дружественные операторы, которым мы разрешаем доступ
    // к личным (private) данным
    friend ostream & operator<< (ostream &, const Complex &);
    friend istream & operator >> (istream &, Complex &);
 
};
 
 
// перегрузка оператора <<
ostream& operator<< (ostream &out, const Complex &c)
{
    out << "(" << c.re << ", " << c.im << ")";
    return out;
}
 
// перегрузка оператора >>
istream& operator >> (istream &in, Complex &c)
{
    in >> c.re >> c.im;
    return in;
}
 
 
 
void top(double r[12][5], double a[6][12])
{
    for (int i = 0; i < 6; i++)
        for (int j = 0; j < 12; j++)
            a[i][j] = 0;
    for (int j = 0; j < 12; j++)
    {
        for (int i = 0; i < 6; i++)
        {
            for (int e = 1; e <= 7; e++)
                for (int c = 1; c <= 7; c++)
                    if (r[j][0] == e && r[j][1] == c)
                    {
                        if (e == i + 1)
                            a[i][j] = 1;
                        if (c == i + 1)
                            a[i][j] = -1;
                    }
        }
    }
}
void tr(double a[6][12], double at[12][6])
{
    for (int i = 0; i < 6; i++)
        for (int j = 0; j < 12; j++)
            at[j][i] = a[i][j];
 
}
void Y(Complex y[12][12], double f, double r[12][5], double p[12][4])
{
    for (int i = 0; i < 12; i++)
        for (int j = 0; j < 12; j++)
            y[i][j] = 0.0;
    for (int i = 0; i < 12; i++)
    {
        double xl, xc;
        xl = 2 * 3.14 * f * r[i][3];
        xc = 1 / (2 * 3.14*f*r[i][4]);
        if (r[i][4] == 0)
            xc = 0;
        Complex z(r[i][2], (xl - xc));
        Complex x(1, 0);
        x = (x / z);
        if (p[i][3] == 0)
        {
            y[i][i] = x;
        }
        else
        {
            y[i][i] = 0.0;
        }
    }
 
}
void mul(double a[6][12], Complex y[12][12], Complex q1[6][12])
{
    for (int i = 0; i < 6; i++)
        for (int j = 0; j < 12; j++)
        {
            q1[i][j] = 0.0;
            for (int k = 0; k < 12; k++)
            {
                Complex x = a[i][k];
                q1[i][j] += x * y[k][j];
            }
 
        }
}
void mul2(Complex a[6][12], double y[12][6], Complex q[6][7])
{
    for (int i = 0; i < 6; i++)
        for (int j = 0; j < 6; j++)
        {
            q[i][j] = 0.0;
            for (int k = 0; k < 12; k++)
            {
                Complex x = a[i][k];
                Complex z(y[k][j]);
                q[i][j] += x * z;
            }
        }
}
void mul3(Complex y[12][12], Complex e[12], Complex q[12])
{
    for (int i = 0; i < 12; i++)
    {
        q[i] = y[i][i] * e[i];
    }
}
void mul4(double a[6][12], Complex y[12], Complex q[6])
{
    for (int i = 0; i < 6; i++)
    {
        q[i] = 0.0;
        for (int k = 0; k < 12; k++)
        {
            Complex x = a[i][k];
            q[i] += x * y[k];
        }
        Complex x = -1.0;
        q[i] = x * q[i];
    }
}
void eds(double r[12][5], double c[12][4], Complex e[12])
{
    for (int i = 0; i < 12; i++)
    {
        if (c[i][0] == r[i][0])
        {
            double x = c[i][2] * cos(c[i][3] * 3.14 / 180);
            double y = c[i][2] * sin(c[i][3] * 3.14 / 180);
            Complex x1(x, 0);
            Complex y1(0, y);
            e[i] = x1 + y1;
 
        }
        else
        {
            if (c[i][0] == r[i][1])
            {
                double x = -c[i][2] * cos(c[i][3] * 3.14 / 180);
                double y = -c[i][2] * sin(c[i][3] * 3.14 / 180);
                Complex x1(x, 0);
                Complex y1(0, y);
                e[i] = x1 + y1;
            }
            else
            {
                e[i] = 0.0;
            }
        }
    }
}
void amp(double r[12][5], double p[12][4], Complex j[12])
{
    for (int i = 0; i < 12; i++)
    {
        if (p[i][0] == r[i][0])
        {
            double x = p[i][2] * cos(p[i][3] * 3.14 / 180);
            double y = p[i][2] * sin(p[i][3] * 3.14 / 180);
            Complex x1(x, 0);
            Complex y1(0, y);
            j[i] = x1 + y1;
        }
        else
        {
            if (p[i][0] == r[i][1])
            {
                double x = -p[i][2] * cos(p[i][3] * 3.14 / 180);
                double y = -p[i][2] * sin(p[i][3] * 3.14 / 180);
                Complex x1(x, 0);
                Complex y1(0, y);
                j[i] = x1 + y1;
            }
            else
            {
                j[i] = 0.0;
            }
        }
    }
}
void add(Complex q[12], Complex j[12], Complex s[12])
{
    for (int i = 0; i < 12; i++)
        s[i] = q[i] + j[i];
}
Complex Amperage(Complex x[7], Complex y[12][12], Complex e[12], Complex j[12], double p[12][4], double r[12][5], Complex I[12], Complex Uj, double f)
{
    for (int i = 0; i < 12; i++)
    {
        if (p[i][3] == 0)
        {
            int x1 = r[i][0];
            int x2 = r[i][1];
            Complex z = x[x1 - 1] - x[x2 - 1];
            Complex c = z + e[i];
            Complex v = c * y[i][i];
            I[i] = v;
        }
        else
        {
            I[i] = j[i];
            int x1 = p[i][0];
            int x2 = p[i][1];
            Complex z1 = x[x1] - x[x2];
            double xl, xc;
            xl = 2 * 3.14 * f * r[i][3];
            xc = 1 / (2 * 3.14*f*r[i][4]);
            if (r[i][4] == 0)
                xc = 0;
            Complex z(r[i][2], (xl - xc));
            Complex c = I[i] * z;
            Complex v = z1 + c;
            Uj = v;
        }
    }
    return Uj;
}
Complex Sp(double p[12][4], double r[12][5], Complex I[12], int f)
{
    Complex Sp = 0.0;
    for (int i = 0; i < 12; i++)
    {
        double xl, xc;
        xl = 2 * 3.14 * f * r[i][3];
        xc = 1 / (2 * 3.14*f*r[i][4]);
        if (r[i][4] == 0)
            xc = 0;
        Complex z(r[i][2], (xl - xc));
        Complex I2 = I[i] * I[i];
        Complex x = z * I2;
        Sp += x;
    }
    return Sp;
}
Complex Si(Complex j[12], Complex e[12], Complex I[12], Complex Uj)
{
    Complex Si = 0.0;
    for (int i = 0; i < 12; i++)
    {
        Complex x = j[i] * Uj;
        Complex r(I[i]);
        Complex c = r.conj();
        Complex y = e[i] * I[i];
        Complex z = x + y;
        Si += z;
    }
    return Si;
}
void Gauss(Complex mas[6][7], Complex x[6])
{
    //прямой ход
    for (int i = 0; i < 6; i++) {
        Complex first = mas[i][i];                      //временная переменная для элемента главной диагонали
        for (int j = 0; j < 7; j++) {
            Complex a(mas[i][j] / first);
            mas[i][j] = (a);                                //деление строки на элемент главной диагонали
        }
        for (int k = i + 1; k < 6; k++) {
            Complex first_in_line = mas[k][i];
            for (int c = i; c < 7; c++) {
                Complex a(mas[i][c] * first_in_line);
                Complex b(a - mas[k][c]);
                mas[k][c] = b;                              //зануление элементов под главной диагональю
            }
        }
    }
    //обратный ход
    x[5] = mas[5][6];
    for (int i = 4; i >= 0; i--) {
        for (int j = 5; j > i; j--) {
            Complex a(mas[i][j] * x[j]);
            Complex b(mas[i][6] - a);
            mas[i][6] = (b);
        }
        x[i] = mas[i][6];
    }
}
int main()
{
    setlocale(LC_ALL, "Russian");
    ifstream inputr("inputr.txt");
    ifstream inputc("inputc.txt");
    ifstream inputp("inputp.txt");
    double r[12][5];
    double c[12][4];
    double p[12][4];
    for (int i = 0; i < 12; i++)
    {
        inputr >> r[i][0] >> r[i][1] >> r[i][2] >> r[i][3] >> r[i][4];
    }
    for (int i = 0; i < 12; i++)
    {
        inputc >> c[i][0] >> c[i][1] >> c[i][2] >> c[i][3];
    }
    for (int i = 0; i < 12; i++)
    {
        inputp >> p[i][0] >> p[i][1] >> p[i][2] >> p[i][3];
    }
    int f;
    inputr >> f;
    double a[6][12]; double at[12][6];
    Complex j[12];
    Complex e[12];
    Complex q[12];
    Complex s[12];
    Complex rr[6];
    Complex y[12][12];
    Complex q1[6][12];
    Complex x[6][7];
    Complex x1[6][6];
    Complex I[12];
    Complex x2[7];
    Complex Uj;
    top(r, a);
    tr(a, at);
    eds(r, c, e);
    amp(r, p, j);
    Y(y, f, r, p);
    mul(a, y, q1);
    mul2(q1, at, x);
    mul3(y, e, q);
    add(q, j, s);
    mul4(a, s, rr);
    //расширенная матрица 
    Complex Extended_matrix[6][7];
    for (int i = 0; i < 6; i++) {
        for (int j = 0; j < 6; j++) {
            Extended_matrix[i][j] = x[i][j];        //заполнение расширенной матрицы значениями проводимостей
        }
        Extended_matrix[i][6] = rr[i];      //заполнение последнего столбца исчтониками тока
    }
    Gauss(Extended_matrix, x2);
    Uj = Amperage(x2, y, e, j, p, r, I, Uj, f);
    Complex Spotr = Sp(p, r, I, f);
    Complex Sist = Si(j, e, I, Uj);
    for (int i = 0; i < 12; i++)
        cout << r[i][0] << " " << r[i][1] << " " << r[i][2] << " " << r[i][3] << " " << r[i][4] << " " << c[i][0] << " " << c[i][1] << " " << c[i][2]
        << " " << c[i][3] << " " << p[i][0] << " " << p[i][1] << " " << p[i][2] << " " << p[i][3] << endl;
    cout << endl;
    cout << endl;
    ofstream res("res.txt");
    for (int i = 0; i < 7; i++)
    {
        res << "fi[" << i + 1 << "]=" << x2[i] << endl;
        cout << "fi[" << i + 1 << "]=" << x2[i] << endl;
    }
    res << endl;
    cout << endl;
    for (int i = 0; i < 12; i++)
    {
        res << "I[" << i + 1 << "]=" << I[i] << endl;
        cout << "I[" << i + 1 << "]=" << I[i] << endl;
    }
    res << "Uj=" << Uj << endl;
    res << "Sпотр=" << Spotr << endl;
    res << "Sист=" << Sist << endl;
    cout << "Uj=" << Uj << endl;
    cout << "Sпотр=" << Spotr << endl;
    cout << "Sист=" << Sist << endl;
    inputr.close();
    inputc.close();
    inputp.close();
    res.close();
    system("pause");
    return 0;
}
0
Лучшие ответы (1)
cpp_developer
Эксперт
20123 / 5690 / 1417
Регистрация: 09.04.2010
Сообщений: 22,546
Блог
27.05.2019, 21:25
Ответы с готовыми решениями:

Использование полного имени в объявлении члена не допускается
Доброго времени суток! Решаю задачи по конструированию простейших классов. При объявлении класса выдает ошибку: использование полного...

Использование полного имени в объявлении члена не допускается
Делаю курсовой проект во ВинАпи, возникла проблема в данном отрывке кода. Копирывал из источника, в котором данной ошибки не было. ...

Использование полного имени в объявлении члена не допускается E0427
class CBaseHandle { public: __forceinline CBaseHandle( ) { m_Index = INVALID_EHANDLE_INDEX; } __forceinline CBaseHandle(...

4
27.05.2019, 21:31

Не по теме:

очень интересно, если бы Толстой дал на проверку "Война и мир" эффект был бы тот же.

0
57 / 43 / 12
Регистрация: 27.10.2018
Сообщений: 454
27.05.2019, 21:34
Цитата Сообщение от Danalala Посмотреть сообщение
Нахождение ошибки
Никто тут ни в чем не разберется ,во-первых отредактируйте сообщение и подайте код в человеческом виде ,а во-вторых явно стоит уточнить в какой именно стороке/строках ошибка/ошибки.
0
19491 / 10097 / 2460
Регистрация: 30.01.2014
Сообщений: 17,805
27.05.2019, 23:34
Лучший ответ Сообщение было отмечено Danalala как решение

Решение

Цитата Сообщение от Danalala Посмотреть сообщение
C++
1
2
3
4
5
6
7
8
double Complex::Re()
{
    return re;
}
double Complex::Im()
{
    return im;
}
Ошибка в определениях этих функций. Нужно удалить Complex::, т.к. определения находятся внутри класса.
2
0 / 0 / 0
Регистрация: 27.05.2019
Сообщений: 2
28.05.2019, 21:02  [ТС]
Во-первых, хотел сказать огромное спасибо Человечищу, который нашёл ошибку, мой поклон Вам.
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
#include "stdafx.h"
#include "pch.h"
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cmath>
 
using namespace std;
 
 
class Complex         // класс "Комплексное число"
{
private:
    double re, im;      // действительная и мнимая части
 
public:
    // конструкторы 
    Complex(double r = 0, double i = 0)
    {
        re = r;
        im = i;
    }
 
    Complex(const Complex &c)   // конструктор копирования
    {
        re = c.re;
        im = c.im;
    }
 
    // деструктор
    ~Complex()
    {
    }
 
    // остальные функции
 
    // Модуль комплексного числа
    double abs() const
    {
        return sqrt(re * re + im * im);
    }
    const Complex conj()
    {
        re = re;
        im = -im;
        return *this;
    }
    // оператор присваивания
    const Complex& operator = (const Complex &c)
    {
        re = c.re;
        im = c.im;
 
        return (*this);
    }
 
 
    // оператор +=
    const Complex& operator += (const Complex &c)
    {
        re += c.re;
        im += c.im;
        return *this;
    }
 
    // оператор сложения
    const Complex operator + (const Complex &c)
    {
        return Complex(re + c.re, im + c.im);
    }
 
    // оператор вычитания
    const Complex operator - (const Complex &c)
    {
        return Complex(re - c.re, im - c.im);
    }
 
    // оператор умножения
    const Complex operator * (const Complex &c)
    {
        return Complex(re * c.re - im * c.im, re * c.im + im * c.re);
    }
    const Complex operator*(const double& a)
    {
        return Complex(re*a, im*a);
    }
    const Complex operator*(double &c)
    {
        Complex fp1;
        double i, j;
        i = re * c;
        j = im * c;
        fp1 = (i, j);
        return fp1;
    }
    // оператор деления
    const Complex operator / (const Complex &c)
    {
        Complex temp;
 
        double r = c.re * c.re + c.im * c.im;
        temp.re = (re * c.re + im * c.im) / r;
        temp.im = (im * c.re - re * c.im) / r;
 
        return temp;
    }
    double Re()
    {
        return re;
    }
    double Im()
    {
        return im;
    }
 
    Complex expon(Complex c)
    {
        c.re = exp(re) * cos(im);
        c.im = exp(re) * sin(im);
        return c;
    }
 
    Complex sinus(Complex c)
    {
        c.re = sin(re) * cosh(im);
        c.im = cos(re) * sinh(im);
        return c;
    }
    Complex cosinus(Complex c)
    {
        c.re = cos(re) * cosh(im);
        c.im = -sin(re) * sinh(im);
        return c;
    }
    // укажем дружественные операторы, которым мы разрешаем доступ
    // к личным (private) данным
    friend ostream & operator<< (ostream &, const Complex &);
    friend istream & operator >> (istream &, Complex &);
 
};
 
 
// перегрузка оператора <<
ostream& operator<< (ostream &out, const Complex &c)
{
    out << "(" << c.re << ", " << c.im << ")";
    return out;
}
 
// перегрузка оператора >>
istream& operator >> (istream &in, Complex &c)
{
    in >> c.re >> c.im;
    return in;
}
 
 
 
void top(double r[12][5], double a[6][12])
{
    for (int i = 0; i < 6; i++)
        for (int j = 0; j < 12; j++)
            a[i][j] = 0;
    for (int j = 0; j < 12; j++)
    {
        for (int i = 0; i < 6; i++)
        {
            for (int e = 1; e <= 7; e++)
                for (int c = 1; c <= 7; c++)
                    if (r[j][0] == e && r[j][1] == c)
                    {
                        if (e == i + 1)
                            a[i][j] = 1;
                        if (c == i + 1)
                            a[i][j] = -1;
                    }
        }
    }
}
void tr(double a[6][12], double at[12][6])
{
    for (int i = 0; i < 6; i++)
        for (int j = 0; j < 12; j++)
            at[j][i] = a[i][j];
 
}
void Y(Complex y[12][12], double f, double r[12][5], double p[12][4])
{
    for (int i = 0; i < 12; i++)
        for (int j = 0; j < 12; j++)
            y[i][j] = 0.0;
    for (int i = 0; i < 12; i++)
    {
        double xl, xc;
        xl = 2 * 3.14 * f * r[i][3];
        xc = 1 / (2 * 3.14*f*r[i][4]);
        if (r[i][4] == 0)
            xc = 0;
        Complex z(r[i][2], (xl - xc));
        Complex x(1, 0);
        x = (x / z);
        if (p[i][3] == 0)
        {
            y[i][i] = x;
        }
        else
        {
            y[i][i] = 0.0;
        }
    }
 
}
void mul(double a[6][12], Complex y[12][12], Complex q1[6][12])
{
    for (int i = 0; i < 6; i++)
        for (int j = 0; j < 12; j++)
        {
            q1[i][j] = 0.0;
            for (int k = 0; k < 12; k++)
            {
                Complex x = a[i][k];
                q1[i][j] += x * y[k][j];
            }
 
        }
}
void mul2(Complex a[6][12], double y[12][6], Complex q[6][7])
{
    for (int i = 0; i < 6; i++)
        for (int j = 0; j < 6; j++)
        {
            q[i][j] = 0.0;
            for (int k = 0; k < 12; k++)
            {
                Complex x = a[i][k];
                Complex z(y[k][j]);
                q[i][j] += x * z;
            }
        }
}
void mul3(Complex y[12][12], Complex e[12], Complex q[12])
{
    for (int i = 0; i < 12; i++)
    {
        q[i] = y[i][i] * e[i];
    }
}
void mul4(double a[6][12], Complex y[12], Complex q[6])
{
    for (int i = 0; i < 6; i++)
    {
        q[i] = 0.0;
        for (int k = 0; k < 12; k++)
        {
            Complex x = a[i][k];
            q[i] += x * y[k];
        }
        Complex x = -1.0;
        q[i] = x * q[i];
    }
}
void eds(double r[12][5], double c[12][4], Complex e[12])
{
    for (int i = 0; i < 12; i++)
    {
        if (c[i][0] == r[i][0])
        {
            double x = c[i][2] * cos(c[i][3] * 3.14 / 180);
            double y = c[i][2] * sin(c[i][3] * 3.14 / 180);
            Complex x1(x, 0);
            Complex y1(0, y);
            e[i] = x1 + y1;
 
        }
        else
        {
            if (c[i][0] == r[i][1])
            {
                double x = -c[i][2] * cos(c[i][3] * 3.14 / 180);
                double y = -c[i][2] * sin(c[i][3] * 3.14 / 180);
                Complex x1(x, 0);
                Complex y1(0, y);
                e[i] = x1 + y1;
            }
            else
            {
                e[i] = 0.0;
            }
        }
    }
}
void amp(double r[12][5], double p[12][4], Complex j[12])
{
    for (int i = 0; i < 12; i++)
    {
        if (p[i][0] == r[i][0])
        {
            double x = p[i][2] * cos(p[i][3] * 3.14 / 180);
            double y = p[i][2] * sin(p[i][3] * 3.14 / 180);
            Complex x1(x, 0);
            Complex y1(0, y);
            j[i] = x1 + y1;
        }
        else
        {
            if (p[i][0] == r[i][1])
            {
                double x = -p[i][2] * cos(p[i][3] * 3.14 / 180);
                double y = -p[i][2] * sin(p[i][3] * 3.14 / 180);
                Complex x1(x, 0);
                Complex y1(0, y);
                j[i] = x1 + y1;
            }
            else
            {
                j[i] = 0.0;
            }
        }
    }
}
void add(Complex q[12], Complex j[12], Complex s[12])
{
    for (int i = 0; i < 12; i++)
        s[i] = q[i] + j[i];
}
Complex Amperage(Complex x[7], Complex y[12][12], Complex e[12], Complex j[12], double p[12][4], double r[12][5], Complex I[12], Complex Uj, double f)
{
    for (int i = 0; i < 12; i++)
    {
        if (p[i][3] == 0)
        {
            int x1 = r[i][0];
            int x2 = r[i][1];
            Complex z = x[x1 - 1] - x[x2 - 1];
            Complex c = z + e[i];
            Complex v = c * y[i][i];
            I[i] = v;
        }
        else
        {
            I[i] = j[i];
            int x1 = p[i][0];
            int x2 = p[i][1];
            Complex z1 = x[x1] - x[x2];
            double xl, xc;
            xl = 2 * 3.14 * f * r[i][3];
            xc = 1 / (2 * 3.14*f*r[i][4]);
            if (r[i][4] == 0)
                xc = 0;
            Complex z(r[i][2], (xl - xc));
            Complex c = I[i] * z;
            Complex v = z1 + c;
            Uj = v;
        }
    }
    return Uj;
}
Complex Sp(double p[12][4], double r[12][5], Complex I[12], int f)
{
    Complex Sp = 0.0;
    for (int i = 0; i < 12; i++)
    {
        double xl, xc;
        xl = 2 * 3.14 * f * r[i][3];
        xc = 1 / (2 * 3.14*f*r[i][4]);
        if (r[i][4] == 0)
            xc = 0;
        Complex z(r[i][2], (xl - xc));
        Complex I2 = I[i] * I[i];
        Complex x = z * I2;
        Sp += x;
    }
    return Sp;
}
Complex Si(Complex j[12], Complex e[12], Complex I[12], Complex Uj)
{
    Complex Si = 0.0;
    for (int i = 0; i < 12; i++)
    {
        Complex x = j[i] * Uj;
        Complex r(I[i]);
        Complex c = r.conj();
        Complex y = e[i] * I[i];
        Complex z = x + y;
        Si += z;
    }
    return Si;
}
void Gauss(Complex mas[6][7], Complex x[6])
{
    //прямой ход
    for (int i = 0; i < 6; i++) {
        Complex first = mas[i][i];                      //временная переменная для элемента главной диагонали
        for (int j = 0; j < 7; j++) {
            Complex a(mas[i][j] / first);
            mas[i][j] = (a);                                //деление строки на элемент главной диагонали
        }
        for (int k = i + 1; k < 6; k++) {
            Complex first_in_line = mas[k][i];
            for (int c = i; c < 7; c++) {
                Complex a(mas[i][c] * first_in_line);
                Complex b(a - mas[k][c]);
                mas[k][c] = b;                              //зануление элементов под главной диагональю
            }
        }
    }
    //обратный ход
    x[5] = mas[5][6];
    for (int i = 4; i >= 0; i--) {
        for (int j = 5; j > i; j--) {
            Complex a(mas[i][j] * x[j]);
            Complex b(mas[i][6] - a);
            mas[i][6] = (b);
        }
        x[i] = mas[i][6];
    }
}
int main()
{
    setlocale(LC_ALL, "Russian");
    ifstream inputr("inputr.txt");
    ifstream inputc("inputc.txt");
    ifstream inputp("inputp.txt");
    double r[12][5];
    double c[12][4];
    double p[12][4];
    for (int i = 0; i < 12; i++)
    {
        inputr >> r[i][0] >> r[i][1] >> r[i][2] >> r[i][3] >> r[i][4];
    }
    for (int i = 0; i < 12; i++)
    {
        inputc >> c[i][0] >> c[i][1] >> c[i][2] >> c[i][3];
    }
    for (int i = 0; i < 12; i++)
    {
        inputp >> p[i][0] >> p[i][1] >> p[i][2] >> p[i][3];
    }
    int f;
    inputr >> f;
    double a[6][12]; double at[12][6];
    Complex j[12];
    Complex e[12];
    Complex q[12];
    Complex s[12];
    Complex rr[6];
    Complex y[12][12];
    Complex q1[6][12];
    Complex x[6][7];
    Complex x1[6][6];
    Complex I[12];
    Complex x2[7];
    Complex Uj;
    top(r, a);
    tr(a, at);
    eds(r, c, e);
    amp(r, p, j);
    Y(y, f, r, p);
    mul(a, y, q1);
    mul2(q1, at, x);
    mul3(y, e, q);
    add(q, j, s);
    mul4(a, s, rr);
    //расширенная матрица 
    Complex Extended_matrix[6][7];
    for (int i = 0; i < 6; i++) {
        for (int j = 0; j < 6; j++) {
            Extended_matrix[i][j] = x[i][j];        //заполнение расширенной матрицы значениями проводимостей
        }
        Extended_matrix[i][6] = rr[i];      //заполнение последнего столбца исчтониками тока
    }
    Gauss(Extended_matrix, x2);
    Uj = Amperage(x2, y, e, j, p, r, I, Uj, f);
    Complex Spotr = Sp(p, r, I, f);
    Complex Sist = Si(j, e, I, Uj);
    for (int i = 0; i < 12; i++)
        cout << r[i][0] << " " << r[i][1] << " " << r[i][2] << " " << r[i][3] << " " << r[i][4] << " " << c[i][0] << " " << c[i][1] << " " << c[i][2]
        << " " << c[i][3] << " " << p[i][0] << " " << p[i][1] << " " << p[i][2] << " " << p[i][3] << endl;
    cout << endl;
    cout << endl;
    ofstream res("res.txt");
    for (int i = 0; i < 7; i++)
    {
        res << "fi[" << i + 1 << "]=" << x2[i] << endl;
        cout << "fi[" << i + 1 << "]=" << x2[i] << endl;
    }
    res << endl;
    cout << endl;
    for (int i = 0; i < 12; i++)
    {
        res << "I[" << i + 1 << "]=" << I[i] << endl;
        cout << "I[" << i + 1 << "]=" << I[i] << endl;
    }
    res << "Uj=" << Uj << endl;
    res << "Sпотр=" << Spotr << endl;
    res << "Sист=" << Sist << endl;
    cout << "Uj=" << Uj << endl;
    cout << "Sпотр=" << Spotr << endl;
    cout << "Sист=" << Sist << endl;
    inputr.close();
    inputc.close();
    inputp.close();
    res.close();
    system("pause");
    return 0;
}
Во-вторых, код заработал, но вместо значений выдаёт в f(1)=(-nan(ind); -nan(ind)), токи (I) получаются:-7.85736e+61, 4.89232e+61 такими числовыми значениями, причём все токи
0
Надоела реклама? Зарегистрируйтесь и она исчезнет полностью.
raxper
Эксперт
30234 / 6612 / 1498
Регистрация: 28.12.2010
Сообщений: 21,154
Блог
28.05.2019, 21:02
Помогаю со студенческими работами здесь

исправить ошибку использование полного имени в объявлении члена не допускается в обьявлении всех методов Get
Помогите исправить ошибку использование полного имени в объявлении члена не допускается в обьявлении всех методов Get(36,44,52 строка и...

Ошибка "Использование полного имени в объявлении члена не допускается"
Подскажите, пожалуйста, почему в 14 строке кода ошибка &quot;Использование полного имени в объявлении члена не допускается&quot;. Читаю книгу...

Класс "Матрица": использование полного имени в объявлении члена не допускается
Создал программу по образцу. выдает ошибку #include &lt;iomanip&gt; #include &lt;iostream&gt; using namespace std; class Matrix ...

Ошибка engine.h (использование полного имени в объявлении члена не допускается)
Всем привет ! Прошу помочь с кодом. При описаний класс и публичных переменных столкнулся с такой проблемой. * Использование...

error C2886: std::cout: использование символа в "using"-объявлении члена не допускается
подскажите плз что ето может бить...если не подключаю файл Nokia.h тогда всьо норм.. #include &quot;stdafx.h&quot; #include...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
5
Ответ Создать тему
Новые блоги и статьи
PhpStorm 2025.3: WSL Terminal всегда стартует в ~
and_y87 14.12.2025
PhpStorm 2025. 3: WSL Terminal всегда стартует в ~ (home), игнорируя директорию проекта Симптом: После обновления до PhpStorm 2025. 3 встроенный терминал WSL открывается в домашней директории. . .
Access
VikBal 11.12.2025
Помогите пожалуйста !! Как объединить 2 одинаковые БД Access с разными данными.
Новый ноутбук
volvo 07.12.2025
Всем привет. По скидке в "черную пятницу" взял себе новый ноутбук Lenovo ThinkBook 16 G7 на Амазоне: Ryzen 5 7533HS 64 Gb DDR5 1Tb NVMe 16" Full HD Display Win11 Pro
Музыка, написанная Искусственным Интеллектом
volvo 04.12.2025
Всем привет. Некоторое время назад меня заинтересовало, что уже умеет ИИ в плане написания музыки для песен, и, собственно, исполнения этих самых песен. Стихов у нас много, уже вышли 4 книги, еще 3. . .
От async/await к виртуальным потокам в Python
IndentationError 23.11.2025
Армин Ронахер поставил под сомнение async/ await. Создатель Flask заявляет: цветные функции - провал, виртуальные потоки - решение. Не threading-динозавры, а новое поколение лёгких потоков. Откат?. . .
Поиск "дружественных имён" СОМ портов
Argus19 22.11.2025
Поиск "дружественных имён" СОМ портов На странице: https:/ / norseev. ru/ 2018/ 01/ 04/ comportlist_windows/ нашёл схожую тему. Там приведён код на С++, который показывает только имена СОМ портов, типа,. . .
Сколько Государство потратило денег на меня, обеспечивая инсулином.
Programma_Boinc 20.11.2025
Сколько Государство потратило денег на меня, обеспечивая инсулином. Вот решила сделать интересный приблизительный подсчет, сколько государство потратило на меня денег на покупку инсулинов. . . .
Ломающие изменения в C#.NStar Alpha
Etyuhibosecyu 20.11.2025
Уже можно не только тестировать, но и пользоваться C#. NStar - писать оконные приложения, содержащие надписи, кнопки, текстовые поля и даже изображения, например, моя игра "Три в ряд" написана на этом. . .
Мысли в слух
kumehtar 18.11.2025
Кстати, совсем недавно имел разговор на тему медитаций с людьми. И обнаружил, что они вообще не понимают что такое медитация и зачем она нужна. Самые базовые вещи. Для них это - когда просто люди. . .
Создание Single Page Application на фреймах
krapotkin 16.11.2025
Статья исключительно для начинающих. Подходы оригинальностью не блещут. В век Веб все очень привыкли к дизайну Single-Page-Application . Быстренько разберем подход "на фреймах". Мы делаем одну. . .
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2025, CyberForum.ru