Skip to content

Commit

Permalink
não acabado
Browse files Browse the repository at this point in the history
	new file:   "Tri\303\242ngulos.cpp"
  • Loading branch information
BhryanS2 committed Jan 4, 2021
1 parent 4fe0c78 commit d405269
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 37 deletions.
25 changes: 13 additions & 12 deletions Exercicios/Campo Minado.cpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
#include<bits/stdc++.h>
using namespace std;

int main() {
int n;
int c[51];
scanf("%d", &n);
for (int i = 0;i < n;i++) {
scanf("%d", &c[i]);
cin >> n;
int c[n];

for (int i = 0; i < n; i++) {
cin >> c[i];
}
for (int i = 0;i < n;i++) {

for (int i = 0; i < n; i++) {
int q = 0;
q = q + c[i];
if (i < n - 1) {
q = q + c[i + 1];
}
if (i > 0) {
q = q + c[i - 1];
}
printf("%d\n", q);
if (i < n - 1) q = q + c[i + 1];
if (i > 0) q = q + c[i - 1];

cout << q << endl;
}
}
17 changes: 11 additions & 6 deletions Exercicios/Código (OBI 2015).cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
#include<bits/stdc++.h>
using namespace std;
int main() {
int n, cont = 0;
scanf("%d", &n);
int v[n];
for (int i = 0;i < n;i++) {
scanf("%d", &v[i]);

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

for (int i = 0;i < n; i++) {
cin >> v[i];
}
for (int i = 0;i < n - 2;i++) {

for (int i = 0;i < n - 2; i++) {
if (v[i] == 1) {
if (v[i + 1] == 0 && v[i + 2] == 0) {
cont++;
}
}
}
printf("%d", cont);
cout << cont;

return 0;
}
28 changes: 9 additions & 19 deletions Exercicios/Fita Colorida.cpp
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{

int main() {
int q, c;

cin >> q;

int v[q];

for (int i = 0;i < q;i++) {
cin >> v[i];
}
for (int i = 0;i < q;i++) cin >> v[i];

for (int i = 0;i < q;i++) {
for (int i = 0; i < q; i++) {
if (v[i] == 0) {
for (int x = i;x < q;x++) {
if (v[x] != 0) {
c++;
v[x] = min(9, c);
}
else {
} else {
c = 0;
}
}
Expand All @@ -34,23 +32,15 @@ else {

if (v[a] != 0) {
c++;
if (v[a] == -1) {
v[a] = min(9, c);
}
else {
v[a] = min(v[a], c);
}
}
else {
v[a] = v[a] == -1 ? min(9, c) : min(v[a], c);
} else {
c = 0;
}
}
}
}

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

return 0;
}
55 changes: 55 additions & 0 deletions Exercicios/Triângulos.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//https://neps.academy/br/exercise/312
//Triângulos
#include <bits/stdc++.h>
#include <math.h>
using namespace std;

bool condicao(int a, int b, int c) {
/*
1 2 1
| b - c | < a < b + c
| a - c | < b < a + c
| a - b | < c < a + b
*/
int BmenosC = b - c, AmenosC = a - c, AmenosB = a - b;

BmenosC = BmenosC < 0 ? BmenosC * -1 : BmenosC;
AmenosC = AmenosC < 0 ? AmenosC * -1 : AmenosC;
AmenosB = AmenosB < 0 ? AmenosB * -1 : AmenosB;

if (BmenosC < a && a < b + c) {
if (AmenosB < c && c < a + b) {
if (AmenosC < b && b < a + c) return true;
else return false;
} else return false;
} else return false;
}

bool pitagoras(int a, int b, int c) {
// a² = b² + c²
int res = b + c;
return a == res ? true : false;
}

int main() {
int a, b, c;

cin >> a >> b >> c;
bool veradeiroOuFalso = condicao(a, b, c);
bool res = pitagoras(pow(a, 2), pow(b, 2), pow(c, 2));

if (veradeiroOuFalso) {
if (a == b && b == c) {
cout << "a" << endl;
}
else {
cout << (res ? "r" : "o") << endl;
}
}
else {
cout << "n" << endl;
}

//cout << endl << pow(a, 2) << " " << pow(b, 2) << " " << pow(c, 2) << " " << pow(b, 2) + pow(c, 2);
}

0 comments on commit d405269

Please sign in to comment.