Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- const int dim_a = 7;
- bool array(int a[], int dim_a, int x, int l)
- {
- int contatore = 1;
- bool trovato = false;
- while(trovato == false)
- {
- for(int i = 0; i < dim_a; i++)
- {
- if(a[i] == a[i+1])
- contatore++;
- if(contatore == l)
- {
- trovato = true;
- cout <<"Trovato.\n";
- return trovato;
- }
- }
- }
- if(trovato == false)
- cout <<"Non c'è.\n";
- return trovato;
- }
- int main()
- {
- int a[dim_a] = {6,4,3,3,2,7,9};
- int x;
- int l;
- cout <<"Inserire il numero da cercare.\n";
- cin >> x;
- cout <<"Quante volte consecutive vuoi cercarlo?\n";
- cin >> l;
- array(a,dim_a,x,l);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement