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

фигуры #94

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
42 changes: 42 additions & 0 deletions 123/film.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include <iostream>
Copy link
Owner

Choose a reason for hiding this comment

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

Во-первых, добавляйте файлы на свою ветку.

Во-вторых, большинство программ я у Вас проверила и написала несколько комментариев, если что-то не отобразилось, то перейдите на вкладку Pull request -> Closed и отфильтруйте все запросы по автору svvan45

В-третьих, проверила Вашу работу по отрисовке фигур. Вы над заданием не видели магический заголовок ООП? Он означает, что при выполнении задания нужно применить принципы ООП.

Copy link
Owner

Choose a reason for hiding this comment

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

Да, классы. Возможно, есть смысл создать абстрактный класс.

#include <string>
#include "film.h"
using namespace std;



int film::set_point(int *arr)
{
for ( int i = 0; i < 3; i++){
int a;
cin >> a;
arr[i] = a;
}
return *arr;
}
float film::sr_point(int *arr)
{
int sum=0;
for (int i = 0; i < 3; i++)
{

sum += arr[i];

}
sr = sum / 3;
return sr;
}
void film::set_name(){
cin >> name;
}
void film::set_year(){
cin >> year;
}
void film::get(){
cout << name << endl;
cout << year << endl;
cout << sr << endl;
}



16 changes: 16 additions & 0 deletions 123/film.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <iostream>
#include <string>
using namespace std;

class film {
private:
string name;
int year;
float sr;
public:
int set_point (int *arr);
float sr_point(int *arr);
void set_name ();
void set_year();
void get ();
};
49 changes: 49 additions & 0 deletions 123/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#include <iostream>
#include <string>
#include "film.h"
using namespace std;

int main(){
int *arr = new int [3];
float arr2[3];
cout << "Write name, year, points: " << endl;
film f1;
f1.set_name();
f1.set_year();
f1.set_point(arr);
arr2[0] = f1.sr_point(arr);
cout << "Write name, year, points: " << endl;
film f2;
f2.set_name();
f2.set_year();
f2.set_point(arr);
arr2[1] = f2.sr_point(arr);
cout << "Write name, year, points: " << endl;
film f3;
f3.set_name();
f3.set_year();
f3.set_point(arr);
arr2[2] = f3.sr_point(arr);

float max = arr2[0];
int t = 0;
for (int i = 1;i < 3; i++ ){
if (max < arr2[i])
{
max = arr2[i];
t = i;
}
}
switch (t)
{
case 0:
f1.get();
break;
case 1:
f2.get();
break;
case 2:
f3.get();
break;
}
}
36 changes: 36 additions & 0 deletions 4.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <iostream>
#include <cmath>
using namespace std;

float ed_v(float dl_v, int a); // Единичный вектор

int main(){
float ed_x, ed_y, ed_z;
int x = 1;
int y = 5;
int z = 3;
float dl_v = sqrt(x*x+y*y+z*z); // Длина вектора
ed_x = ed_v(dl_v,x);
ed_y = ed_v(dl_v,y);
ed_z = ed_v(dl_v,z);
cout << "Koordinati vtorogo vektora" << endl;
int x1, y1, z1;
cin >> x1;
cin >> y1;
cin >> z1;
int skal_proizved = x*x1+y*y1+z*z1;
int v_pr_i, v_pr_j, v_pr_k; // Векторное произведение
cout << "Skalyarnoe proizvedenie= " << skal_proizved << "\tEdinichiniy vektor: (" << ed_x << ";" << ed_y << ";" << ed_z << ")" << endl;
v_pr_i = y*z1 - y1*z;
v_pr_j = x1*z - x*z1;
v_pr_k = x*y1 - x1*y;
cout << "Vektornoe proizvedenie= " << "(" << v_pr_i << ";" << v_pr_j << ";" << v_pr_k << ")" << endl;



}

float ed_v(float dl_v, int a){
float b = a / dl_v;
return b;
}
53 changes: 53 additions & 0 deletions 5.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#include <iostream>
#include <cmath>

using namespace std;

float perimetr(float a);
float perimetr(float a, float b);
float perimetr(float a, float b, float c, float d);
float square(float a);
float square(float a, float b);
float square(float a, float b, float h);
int main(){
float pi = 3.14;
float a;
float b,c,d,h;
cout << "Vvedite storony kvadrata" << endl;
cin >> a;
cout << "square kvadrata = " << square(a) << "\nperimetr kvadrata = " << perimetr(a) << endl;
cout << "Vvedite R kruga" << endl;
cin >> a;
cout << "square kruga = " << square(pi,a) << "\nperimetr kruga = " << perimetr(a,pi) << endl;
cout << "Vvedite storoni trapecii(a,b - storoni osnovaniya) i visoty" << endl;
cout << "a:";
cin >> a;
cout << "b:";
cin >> b;
cout << "c:";
cin >> c;
cout << "d:";
cin >> d;
cout << "h:";
cin >> h;
cout << "square trapecii = " << square(a,b,h) << "\nperimetr trapecii = " << perimetr(a,b,c,d) << endl;//123
}

float perimetr(float a){
return 4*a;
}
float perimetr(float a, float pi){
return 2*a*pi;
}
float perimetr(float a, float b, float c, float d){
return a+b+c+d;
}
float square(float a){
return a*a;
}
float square(float pi, float b){
return pi*b*b;
}
float square(float a, float b, float h){
return ((a+b)/2)*h;
}
16 changes: 16 additions & 0 deletions AppA.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
float funk( float a, float b,float x) {
float y;
while (x < 0.36)
{
y = asin(pow(x,a)) + acos(pow(x,b));
x = x+ 0.05;
cout << " ";
printf ("%g", y);
}
cout << "\n";
return 0;
}
17 changes: 17 additions & 0 deletions AppB.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
float funk( float a, float b, float _array_x[],int n){
float y;


for (int i=0; i<n; i++)
{
y = asin(pow(_array_x[i],a)) + acos(pow(_array_x[i],b));
std::cout << " ";
printf ("%g", y);

}
return 0;
}
92 changes: 92 additions & 0 deletions din_arr.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#include <iostream>
#include <random>
using namespace std;


void fun(int rows,int col,int **arr){
srand( time(0) );
for ( int i=0; i < rows; i++)
for ( int j=0; j < col; j++)
arr[i][j]= rand() % 30;

}
void fun2(int rows,int col,int **arr){
for ( int i=0; i < rows; i++){
for ( int j=0; j < col; j++)
cout << arr[i][j] << "\t";
cout << endl;
}
}

void fun3(int rows, int col,int n,int **arr){
for ( int i=0; i < rows; i++){
for ( int j=0; j < col; j++){
if (arr[i][j] > n){
n=arr[i][j];

}
}

}
cout << "MAX из элементов = " << n <<endl;
n=0;
}
void fun4 (int rows,int col,int n, int **arr,int *arr2){
for ( int i=0; i < rows; i++){
for ( int j=0; j < col; j++){
if (arr[i][j] > n){
n=arr[i][j];

}

}
cout << "MAX из строки = " << n <<endl;
arr2[i]=n;
n=0;
}
}
void fun5(int rows,int *arr){
for(int i=0; i < rows; i++)
{
cout << arr[i] <<"\t";
}
}


int main() {
int n=0;
int rows;
int col;


cout << "rows = ";
cin >> rows;

cout << "col = ";
cin >> col;

int *arr = new int [rows];

int **arr2 = new int *[rows];
for (int i=0; i<rows;i++)
arr2[i]=new int [col];


fun(rows,col,arr2);
fun2(rows,col,arr2);
fun3( rows, col,n,arr2);
fun4 (rows, col,n,arr2,arr);

cout <<endl;
cout << "массив с MAX значениями: " <<endl;

fun5 ( rows, arr);

for ( int i=0; i < rows; i++)
delete [] arr2[i];
delete [] arr2;



delete [] arr;
}
1 change: 1 addition & 0 deletions folder.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

2 changes: 2 additions & 0 deletions function.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
float funk( float a, float b, float x);
float funk( float a,float b, float _array_x[],int n);
18 changes: 18 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <iostream>
#include <cstdio>
#include <cmath>
#include "function.h"
#include "objects.h"
using namespace std;


int main()
{
float _array_x[5] = {0.08, 0.26, 0.35, 0.41, 0.53};
int n = sizeof(_array_x)/sizeof(_array_x[0]);
int result = funk( a, b, x);
std::cout << "\n " << std::endl;
int result2 = funk( a, b, _array_x,n);
std::cout << "\n " << std::endl;
return 0;
}
Loading