Skip to content
Snippets Groups Projects
Commit edf75de7 authored by Adrien Rougny's avatar Adrien Rougny
Browse files

renommage progs procedures

parent afdf3e41
No related branches found
No related tags found
No related merge requests found
Showing
with 219 additions and 0 deletions
#include <iostream>
#include <vector>
using namespace std;
int g(int n) {
int i, r = 0;
for (i = 1; i <=n; i++)
r += i;
return r;
}
void f(vector<int> &t, int a, int b) {
int c;
if (a < t.size() && b < t.size()) {
c = g(t[a]);
t[a] = g(t[b]);
t[b] = c;
}
}
int main() {
vector<int> tab = {2, 4, 5, 8};
f(tab, 2, 3);
cout << tab[3] << endl;
return 0;
}
#include <iostream>
using namespace std;
void g(int i) {
i = i*2;
}
void f(int &i) {
i = i+3;
g(i);
}
int main() {
int i;
cin >> i;
f(i);
cout << i << endl;
return 0;
}
#include <iostream>
#include <vector>
using namespace std;
int g(int n) {
int i, r = 0;
for (i = 1; i <=n; i++)
r += i;
return r;
}
void f(vector<int> &t, int a, int b) {
int c;
if (a < t.size() && b < t.size()) {
c = g(t[a]);
t[a] = g(t[b]);
t[b] = c;
}
}
int main() {
vector<int> tab = {3, 1, 2, 6};
f(tab, 1, 3);
cout << tab[1] << endl;
return 0;
}
#include <iostream>
using namespace std;
void g(int &i, int j) {
i = i+j;
}
void f(int i, int &j) {
i = i+3;
g(i, j);
}
int main() {
int i;
int j;
cin >> i;
j = j+5;
f(i, j);
cout << i << endl;
return 0;
}
#include <iostream>
#include <vector>
using namespace std;
int g(int n) {
return (n + 1) * (n - 1);
}
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() {
vector<int> tab = {2, 4, 5, 8};
int r = -1;
int x = 2;
int y = 3;
f(tab, x, y, r);
cout << r << endl;
return 0;
}
#include <iostream>
#include <vector>
using namespace std;
int g(int n) {
return (n + 1) * (n - 1);
}
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() {
vector<int> tab = {3, 1, 2, 6};
int r = -1;
int x = 0;
int y = 2;
f(tab, x, y, r);
cout << r << endl;
return 0;
}
#include <iostream>
#include <vector>
using namespace std;
void blourg(vector<int> t, int v, int i, bool &b) {
i=-1;
b=false;
for( int j=0; j<t.size();j++) {
if(t[j] == v) {
i=j;
b=true;
}
}
}
int main() {
bool toto;
vector<int> tab = {4, 10, 13, 7, 5, 6};
int s = 0;
blourg(tab,2,s,toto);
if(toto) cout << s << endl;
else cout << "blourg" << endl;
}
File added
#include <iostream>
#include <fstream>
using namespace std;
int main() {
ofstream fichier("essai.txt");
fichier << 10 << 24 << endl;
fichier.close();
ifstream fichier2("essai.txt");
int i;
fichier2 >> i;
fichier2.close();
cout << i << endl;
return 0;
}
File added
#include <iostream>
#include <sstream>
using namespace std;
int main() {
istringstream a("12 1 4 5");
int j, k, i;
a >> j >> k >> i;
cout << i << endl;
return 0;
}
File added
#include <iostream>
#include <sstream>
using namespace std;
int main() {
istringstream flux("12 14.5 13 4");
int j, k, i;
string s;
flux >> j >> k >> s >> i;
cout << k << " " << s << " " << i << endl;
return 0;
}
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