Skip to content
Snippets Groups Projects
Commit ba78c58e authored by frederic gruau's avatar frederic gruau
Browse files
parents 219a6e1c addf3ca4
No related branches found
No related tags found
No related merge requests found
......@@ -25,9 +25,7 @@ int main() {
f(tab, 2, 3);
for (i = 0; i < tab.size(); i++)
cout << tab[i] << " ";
cout << endl;
cout << tab[3] << endl;
return 0;
}
\ No newline at end of file
......@@ -25,9 +25,7 @@ int main() {
f(tab, 1, 3);
for (i = 0; i < tab.size(); i++)
cout << tab[i] << " ";
cout << endl;
cout << tab[1] << endl;
return 0;
}
\ No newline at end of file
......@@ -7,31 +7,21 @@ int g(int n) {
return (n + 1) * (n - 1);
}
void f(vector<int> t, int a, int b, bool &c, int &d) {
if (a == b || t[a] == t[b]) c = false;
else {
if (t[a] < t[b]) {
c = true;
d = g(t[b] - t[a]);
} else {
c = false;
d = g(t[a] - t[b]);
}
}
void f(vector<int> t, int a, int b, int &c) {
if (t[a] < t[b]) c = g(t[b] - t[a]);
else c = g(t[a] - t[b]);
}
int main() {
int i;
vector<int> tab = {2, 4, 5, 8};
bool b;
int r = -1;
int x = 2;
int y = 3;
f(tab, x, y, b, r);
f(tab, x, y, r);
cout << tab[x] << (b ? " < " : " >= ") << tab[y] <<
", r = " << r << endl;
cout << r << endl;
return 0;
}
\ No newline at end of file
......@@ -7,31 +7,21 @@ int g(int n) {
return (n + 1) * (n - 1);
}
void f(vector<int> t, int a, int b, bool &c, int &d) {
if (a == b || t[a] == t[b]) c = false;
else {
if (t[a] < t[b]) {
c = true;
d = g(t[b] - t[a]);
} else {
c = false;
d = g(t[a] - t[b]);
}
}
void f(vector<int> t, int a, int b, int &c) {
if (t[a] < t[b]) c = g(t[b] - t[a]);
else c = g(t[a] - t[b]);
}
int main() {
int i;
vector<int> tab = {3, 1, 2, 6};
bool b;
int r = -1;
int x = 0;
int y = 2;
f(tab, x, y, b, r);
f(tab, x, y, r);
cout << tab[x] << (b ? " < " : " >= ") << tab[y] <<
", r = " << r << endl;
cout << r << endl;
return 0;
}
\ No newline at end of file
#include <iostream>
using namespace std;
void Blaise(int &acc, int n) {
acc = n * (n+1) / 2;
}
int main() {
int somme = 0;
Blaise(somme, 8);
cout << "Blaise dit que la somme est de : " << somme << endl;
return 0;
}
#include <iostream>
#include <math.h>
using namespace std;
bool premier(int n) {
if (n % 2 == 0) return true;
for (int d = 3; floor(sqrt(n)+1); d=d+2)
if (n % d == 0)
return false;
return true;
}
int main() {
if (premier(21))
cout << "Prim" << endl;
else
cout << "Pas Prim" << endl;
return 0;
}
#include <iostream>
using namespace std;
void Blaise(int &acc, int n) {
acc = n * (n+1) / 2;
}
int main() {
int somme = 0;
Blaise(somme, 8);
cout << "Blaise dit que la somme est de : " << somme << endl;
return 0;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment