Skip to content
Snippets Groups Projects
Commit 91150016 authored by Adeline Pierrot's avatar Adeline Pierrot
Browse files

ajout d'exos recherche dans un tableau

parent f8616ac7
No related branches found
No related tags found
No related merge requests found
Showing
with 345 additions and 0 deletions
#include <iostream>
#include <vector>
using namespace std;
int recherche(int x, vector<int> t) {
for(int i=0; i<t.size(); i=i+1) {
if (t[i]==x) {
return i;
}
}
return -1;
}
int main() {
vector<int> tab = {3,5,4,6};
cout << recherche(5, tab) << endl;
}
#include <iostream>
#include <vector>
using namespace std;
int recherche(int x, vector<int> t) {
for(int i=0; i<t.size(); i=i+1) {
if (t[i]==x) {
return i;
}
}
return -1;
}
int main() {
vector<int> tab = {3,5,4,5};
cout << recherche(5, tab) << endl;
}
#include <iostream>
#include <vector>
using namespace std;
int recherche(int x, vector<int> t) {
for(int i=0; i<t.size(); i=i+1) {
if (t[i]==x) {
return i;
}
}
return -1;
}
int main() {
vector<int> tab = {3,6,4,6};
cout << recherche(5, tab) << endl;
}
#include <iostream>
#include <vector>
using namespace std;
int recherche(int x, vector<int> t) {
for(int i=0; i<t.size(); i=i+1) {
if (t[i]==x) {
return i;
}
return -1;
}
}
int main() {
vector<int> tab = {3,5,4,6};
cout << recherche(5, tab) << endl;
}
#include <iostream>
#include <vector>
using namespace std;
int recherche(int x, vector<int> t) {
for(int i=0; i<t.size(); i=i+1) {
if (t[i]==x) {
return i;
}
return -1;
}
}
int main() {
vector<int> tab = {3,5,4,5};
cout << recherche(5, tab) << endl;
}
#include <iostream>
#include <vector>
using namespace std;
int recherche(int x, vector<int> t) {
for(int i=0; i<t.size(); i=i+1) {
if (t[i]==x) {
return i;
}
return -1;
}
}
int main() {
vector<int> tab = {3,6,4,6};
cout << recherche(5, tab) << endl;
}
#include <iostream>
#include <vector>
using namespace std;
int recherche(int x, vector<int> t) {
int indice = -1;
for(int i=0; i<t.size(); i=i+1) {
if (t[i]==x) {
indice = i;
}
}
return indice;
}
int main() {
vector<int> tab = {3,5,4,6};
cout << recherche(5, tab) << endl;
}
#include <iostream>
#include <vector>
using namespace std;
int recherche(int x, vector<int> t) {
int indice = -1;
for(int i=0; i<t.size(); i=i+1) {
if (t[i]==x) {
indice = i;
}
}
return indice;
}
int main() {
vector<int> tab = {3,5,4,5};
cout << recherche(5, tab) << endl;
}
#include <iostream>
#include <vector>
using namespace std;
int recherche(int x, vector<int> t) {
int indice = -1;
for(int i=0; i<t.size(); i=i+1) {
if (t[i]==x) {
indice = i;
}
}
return indice;
}
int main() {
vector<int> tab = {3,6,4,6};
cout << recherche(5, tab) << endl;
}
#include <iostream>
#include <vector>
using namespace std;
int recherche(int x, vector<int> t) {
int indice = -1;
for(int i=0; i<t.size(); i=i+1) {
if (t[i]==x) {
indice = i;
} else {
indice = -1;
}
}
return indice;
}
int main() {
vector<int> tab = {3,5,4,6};
cout << recherche(5, tab) << endl;
}
#include <iostream>
#include <vector>
using namespace std;
int recherche(int x, vector<int> t) {
int indice = -1;
for(int i=0; i<t.size(); i=i+1) {
if (t[i]==x) {
indice = i;
} else {
indice = -1;
}
}
return indice;
}
int main() {
vector<int> tab = {3,5,4,5};
cout << recherche(5, tab) << endl;
}
#include <iostream>
#include <vector>
using namespace std;
int recherche(int x, vector<int> t) {
int indice = -1;
for(int i=0; i<t.size(); i=i+1) {
if (t[i]==x) {
indice = i;
} else {
indice = -1;
}
}
return indice;
}
int main() {
vector<int> tab = {3,6,4,6};
cout << recherche(5, tab) << endl;
}
#include <iostream>
#include <vector>
using namespace std;
int recherche(int x, vector<int> t) {
int indice = -1;
for(int i=t.size()-1; i>=0; i=i-1) {
if (t[i]==x) {
indice = i;
} else {
indice = -1;
}
}
return indice;
}
int main() {
vector<int> tab = {3,5,4,6};
cout << recherche(5, tab) << endl;
}
#include <iostream>
#include <vector>
using namespace std;
int recherche(int x, vector<int> t) {
int indice = -1;
for(int i=t.size()-1; i>=0; i=i-1) {
if (t[i]==x) {
indice = i;
} else {
indice = -1;
}
}
return indice;
}
int main() {
vector<int> tab = {3,5,4,5};
cout << recherche(5, tab) << endl;
}
#include <iostream>
#include <vector>
using namespace std;
int recherche(int x, vector<int> t) {
int indice = -1;
for(int i=t.size()-1; i>=0; i=i-1) {
if (t[i]==x) {
indice = i;
} else {
indice = -1;
}
}
return indice;
}
int main() {
vector<int> tab = {3,6,4,6};
cout << recherche(5, tab) << endl;
}
#include <iostream>
#include <vector>
using namespace std;
int recherche(int x, vector<int> t) {
for(int i=t.size()-1; i>=0; i=i-1) {
if (t[i]==x) {
return i;
}
}
return -1;
}
int main() {
vector<int> tab = {3,5,4,6};
cout << recherche(5, tab) << endl;
}
#include <iostream>
#include <vector>
using namespace std;
int recherche(int x, vector<int> t) {
for(int i=t.size()-1; i>=0; i=i-1) {
if (t[i]==x) {
return i;
}
}
return -1;
}
int main() {
vector<int> tab = {3,5,4,5};
cout << recherche(5, tab) << endl;
}
#include <iostream>
#include <vector>
using namespace std;
int recherche(int x, vector<int> t) {
for(int i=t.size()-1; i>=0; i=i-1) {
if (t[i]==x) {
return i;
}
}
return -1;
}
int main() {
vector<int> tab = {3,6,4,6};
cout << recherche(5, tab) << endl;
}
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