Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rau maria #87

Open
wants to merge 19 commits into
base: Rau_Maria
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions заадание2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include <iostream>
#include <cmath>
using namespace std;

float VectorLength(int x, int y, int z)
{
return sqrt(x * x + y * y + z * z);
}
void SingleVector(int x, int y, int z, float length)
{
cout << x / length << " " << y / length << " " << z / length << endl;

}
float ScalarProduct(int x, int a, int y, int b, int z, int c)
{
return x * a + y * b + z * c;
}
void VectorProduct(int x, int a, int y, int b, int z, int c)
{
cout << y * c - z * b << " " << -1 * (x * c - z * a) << " " << x * b - y * a << endl;
}
int main(int args, char* argv[])
{
int x = 1;
int y = 5;
int z = 3;
int a, b, c;

cout << "1.1" << endl;
float length = VectorLength(x, y, z);

cout << "Vector Length = " << length << endl;

cout << "1.3" << endl;

cin >> a >> b >> c;

cout << ScalarProduct(x, a, y, b, z, c) << endl;

cout << "1.4" << endl;

VectorProduct(x, y, z, a, b, c);


return 0;
};
25 changes: 25 additions & 0 deletions задание1.17.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <iostream>
#include <cmath>

int main(int args, char* argv[]) {
using namespace std;

const float a = 0.1;
const float b = 0.5;

float x = 0.15;
float xk = 1.37;
float dx = 0.25;

for (; x < xk; x += dx) {
cout << ((a+(tg(bx)*tg(bx)))/(b+(ctg(ax)*ctg(ax))))) << endl;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

откуда bx и ax появились?)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a и b это коэффициенты при х знака умножения не хватает

};

float xs[5] = { 1.9, 2.15, 2.34, 2.73, 3.16 };

for (auto x : xs) {
cout << ((a+(tg(bx)*tg(bx)))/(b+(ctg(ax)*ctg(ax))))) << endl;
};

return 0;
};
45 changes: 45 additions & 0 deletions задание4.1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include <iostream>
#include <cmath>
#include<windows.h>

using namespace std;
float prod(int);
float divis(int);


int main()
{
{
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

зачем эта скобка?

SetConsoleOutput(CP_UTF8)
int a, b, num;
cout » "enter first number"
cin » a « endl;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Запись совсем не смущает? Нет ; в 15 строке, в 16 вообще ужас творится))

cout » "enter second number"
cin » b « endl;
cout » "enter operation number"
cin » num « endl;
switch (num) :
case 1:
cout « prod(a, b) « endl;
break;
case 2:
cout « divis(a, b) « endl;
break;
default:
cout « "1 -multiplication, 2 - division" « endl;
break;

return 0;

}

float prod(int a, int b)
{
return a * b;
}
float divis(int a, int b)
{
return 0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

сразу возвращаем 0, без каких-либо операций?)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

сразу возвращаем 0, без каких-либо операций?)

нужно было вызвать деструктор,сейчас исправлю

}
return(a / b);
}
31 changes: 31 additions & 0 deletions задание4.4.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <iostream>
#include <cmath>
#include<windows.h>

using namespace std;

int main()
{
SetConsoleCP(CP_UTF8);
SetConsoleOutputCP(CP_UTF8);
int a;
int b;
int sum = 0;
cout « "введите начало";
cin » a;
cout « "конец";
cin » b;

while (a <= b)
{
//if (a % 2 == 0)
//{
// sum += a;
//
//}
sum += (a % 2 == 0) ? a : 0;
a += 1;
}
cout « "сумма=" « sum « endl;
return 0;
}
19 changes: 19 additions & 0 deletions задание5.1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <iostream>

using namespace std;

void per(int *x, int *y, int *a)
{
cout << *x << endl;
cout << *y << endl;
cout << *a;

}

int main()
{
int x = 8, y = 30, a = 0;

per(&x, &y, &a);

}
24 changes: 24 additions & 0 deletions задание5.2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <iostream>

using namespace std;

void foo(float *x, float *y)
{
float *t;
t = x;
x = y;
y = t;

cout << *x << endl;
cout<< *y;

}

int main()
{
float x = 34.5;
float y = 69.7;

foo(&x, &y);

}
35 changes: 35 additions & 0 deletions задание5.3.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <iostream>
#include <ctime>

using namespace std;


int main()
{
srand(time(NULL));

int n;
int min = 888;

cin >> n;
int *a = new int[n];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Если выделяете динамически память, то в конце ее нужно освобождать

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

нужно вызвать деструктор,сейчас исправлю


for (int i = 0; i < n; i++) {

a[i] = rand() % 100;
}

for (int i = 0; i < n; i++)
{
cout << a[i] << "\t";
}
for (int i = 0; i < n; i++) {
if (a[i] < min) {
min = a[i];
}
}
cout << endl;
cout << min;

return 0;
}
37 changes: 37 additions & 0 deletions задание5.4.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include <iostream>
#include <ctime>

using namespace std;

void start(int *a, int n)
for (int i = 0; i < n; i++) {

a[i] = rand() % 100;
}

void display( int *a, int n)
for (int i = 0; i < n; i++)
{
cout << a[i] << "\t";
}
void tytmin( int *a, int n, int min)
for (int i = 0; i < n; i++) {
if (a[i] < min) {
min = a[i];
}
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вы вообще код запускали? У Вас каждая функция без фигурных скобок

int main()
{
srand(time(NULL));

int n;
int min = 888;

cin >> n;
int *a = new int[n];

cout << endl;
cout << min;

return 0;
}
79 changes: 79 additions & 0 deletions задание5.5.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#include <iostream>
#include <ctime>

using namespace std;

void FindMin(int **masiv, int row, int col, int *masivaa)
{
int min = 965;

for (int i = 0; i < row; i++)
{
min = 965;

for (int j = 0; j < col; j++)
{
if (masiv[i][j] < min)
{
min = masiv[i][j];
}

}
masivaa[i] = min;
}

cout << "Minimum = { ";

for (int i = 0; i < row; i++)
{
cout << masivaa[i] << " ";
}

cout << "}" << endl;

}

int main()
{
srand(time(NULL));

int row;
int col;

cin >> row;
cin >> col;
cout << endl;


int** masiv = new int* [row];
for (int i = 0; i < row; i++)
{
masiv[i] = new int[col];
}

for (int i = 0; i < row; i++)
{
for (int j = 0; j < col; j++)
{
masiv[i][j] = rand() % 100;
}

}

for (int i = 0; i < row; i++)
{
for (int j = 0; j < col; j++)
{
cout << masiv[i][j] << "\t";
}

cout << endl;
}
cout << endl;


int *masivaa = new int[row];

FindMin(masiv, row, col, masivaa);

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут тоже память не освобождается

}
23 changes: 23 additions & 0 deletions задание6.1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <iostream>
#include <cmath>

using namespace std;

void function(int f[])
{
for (int n = 3; n < 16; n++)
{
f[n] = f[n - 1] + f[n - 2] + f[n - 3];
cout << f[n];
}
}

int main()
{
int f[15];
f[0] = 0;
f[1] = 3;
f[2] = 5;
function(f);

}
Loading