Skip to content
Snippets Groups Projects
Commit addf3ca4 authored by Alexandra Zaharia's avatar Alexandra Zaharia
Browse files

Simplifié exercices procedure_calling_procedure

parent 15c0ccaa
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
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