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

P3121 Napad Danil task-10 #518

Open
wants to merge 1 commit into
base: task-10
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
11 changes: 11 additions & 0 deletions src/main/cpp/t01_sort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,22 @@
//1 2 3 4 5

#include "t01_sort.h"
#include <algorithm>
#include <iostream>


using namespace std;

int t01_sort() {
int N;
cin >> N;
int a[N];

for (int i = 0; i < N; i++) cin >> a[i];

sort(a, a + N);

for (int i = 0; i < N; ++i) cout << a[i] << ' ';

return 0;
}
26 changes: 25 additions & 1 deletion src/main/cpp/t02_shoes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,29 @@
using namespace std;

int t02_shoes() {

int size, N;
int coup = 0;
cin >> size >> N;
int a[N];

for (int i=0; i < N; i++) cin >> a[i];


for (int i = 0; i < N; i++)
if (size < a[i]) {
size = a[i];
coup ++;
break;
}

for (int i = 0; i < N; i++)
if (a[i] - size >= 3)
{
size = a[i];
coup ++;
}


cout << coup;
return 0;
}
31 changes: 29 additions & 2 deletions src/main/cpp/t03_points.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,38 @@
//2 3

#include "t03_points.h"
#include <vector>
#include <math.h>
#include <algorithm>
#include <iostream>


using namespace std;

struct point {
int x;
int y;
double r;
};

bool test(point v1, point v2)
{
return v1.r < v2.r;
};

int t03_points() {

}
int n;
cin >> n;
vector <point> v(n);

for (int i = 0; i < n; i++) {
cin >> v[i].x >> v[i].y;
v[i].r = sqrt( v[i].x * v[i].x + v[i].y * v[i].y );
}

sort(v.begin(), v.end(), test);

for (int i = 0; i < n; i++)
cout << v[i].x << ' ' << v[i].y << endl;
return 0;
}
32 changes: 31 additions & 1 deletion src/main/cpp/t04_students.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,41 @@
//Sergey Petrov

#include "t04_students.h"
#include <vector>
#include <algorithm>
#include <iostream>

using namespace std;

struct student {
string family;
string name;
int math;
int phys;
int comp;
double mean;
};

bool test(student v1, student v2)
{
return v1.mean > v2.mean;
}

int t04_students() {

int n;
cin >> n;
vector <student> v(n);

for (int i = 0; i < n; i++)
{
cin >> v[i].family >> v[i].name >> v[i].math >> v[i].phys >> v[i].comp;
v[i].mean = v[i].math + v[i].phys + v[i].comp;
};

sort(v.begin(), v.end(), test);

for (int i = 0; i < n; i++)
cout << v[i].family << ' ' << v[i].name << endl;
return 0;
}