complex new_complex(float a, float b) // задать значение комплексному числу
{ complex temp;
temp.re=a;
temp.im=b;
return temp;
};
complex plus_complex(complex a, complex b) // сложить два комплексных чисел
{ complex temp;
temp.re=a.re+b.re;
temp.im=a.im+b.im;
return temp;
}
int main() // простая тестовая программа
{
complex z;
printf( "vvedite re и im 1 chisla: ");
cin > > z.re > > z.im;
print( "z", z); printf("\n");
complex q;
printf( "vvedite re и im 2 chisla: ");
cin > > q.re > > q.im;
print("q", q); printf("\n");
complex sum;
sum=plus_complex(z,q);
print("q+z", sum); printf("\n");
return 0;
}
0
moidela87
13.01.2023
Const n = 10; var i, imin: integer; a: array[1..n]of integer; begin imin : = 2; for i : = 1 to n do begin a[i] : = random(100) - 50; if (i mod 2 = 0) and (a[imin] > a[i]) then imin : = i; end; writeln('a[', imin, '] = ', a[imin]); {вторая часть} writeln(); a[1] : = 2; for i : = 2 to n do a[i] : = 2 * a[i - 1]; for i : = 1 to n do write(a[i], ' '); end.
books
13.01.2023
1. var a: array [1..11] of integer; i, min, imin: integer; begin for i: =1 to 10 do read(a[i]); min: =32000; imin: =0; for i: =1 to 10 do if (a[i] mod 2) = 0 then if a[i]< min then begin min: =a[i]; imin: =i; end; write('минимальное: ', min, ' индекс: ', imin); end.2.function stepen(c, s: integer): integer; varj, rez: integer; beginrez: =c; for j: =1 to (s-1) do rez: =rez*c; stepen: =rez; end; vara: array [1..11] of integer; i, min, imin: integer; beginfor i: =1 to 10 do a[i]: =stepen(2, i); for i: =1 to 10 do write(a[i], ' '); end.если возникли вопросы или ошибки в ходе работы программы, пиши в комментариях.
ответ:
#include "stdafx.h"
#include
using namespace std;
struct complex // структура "хранения" комплексного числа
{ float re; // действительная часть
float im; // мнимая часть
};
void print( char * txt, complex x) // вывод комплексного числа
{
printf("%s=(%f,%fi)", txt, x.re, x.im);
return;
};
complex new_complex(float a, float b) // задать значение комплексному числу
{ complex temp;
temp.re=a;
temp.im=b;
return temp;
};
complex plus_complex(complex a, complex b) // сложить два комплексных чисел
{ complex temp;
temp.re=a.re+b.re;
temp.im=a.im+b.im;
return temp;
}
int main() // простая тестовая программа
{
complex z;
printf( "vvedite re и im 1 chisla: ");
cin > > z.re > > z.im;
print( "z", z); printf("\n");
complex q;
printf( "vvedite re и im 2 chisla: ");
cin > > q.re > > q.im;
print("q", q); printf("\n");
complex sum;
sum=plus_complex(z,q);
print("q+z", sum); printf("\n");
return 0;
}
0