Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<fstream>
- using namespace std;
- int main()
- {
- ifstream IN("input");
- ofstream OUT("output");
- if(IN&&OUT)
- {
- int X[400], P[20], n_el, dimP;
- for(int i=0;i<400;i++)
- {
- X[i]=0;
- }
- for(int i=0;i<20;i++)
- {
- P[i]=20;
- }
- IN>>n_el;
- for(int i=0;i<n_el;i++)
- {
- IN>>X[i];
- }
- IN>>dimP;
- for(int i=0;i<dimP;i++)
- {
- IN>>P[i];
- }
- match(X, n_el, P, dimP, i, count_match, OUT);
- OUT>>"fine"<<endl;
- IN.close();
- OUT.close();
- }
- else
- OUT<<"errore con i files"<<endl;
- }
- void match(int *X,int *P,int dimX,int dimP, int i, int count_match, ofstream&OUT)
- {
- if(dimX<dimP-1)
- {
- return;
- }
- else
- //condizione che mi blocca la ricorsione
- {
- int count_match=0;
- if(trovato(int X,int P, int dimP,int i))
- {
- count_match++;
- OUT<<"Match n "<<count_match<<"a partire dalla posizione "<<i<<endl;
- }
- match(int X+1,int P,int dimP, int i+1, int count_match,ofstream&OUT)
- }
- }
- bool trovato(int *X,int*P,int dimP,int indice)
- {
- int indice=0;
- bool trovato=true;
- if(dimP==0)
- {
- return trovato;
- }
- else //caso che devo discutere
- {
- if(X[indice]!=P[indice])
- {
- trovato=false;
- return trovato;
- }
- else
- {
- trovato(int X,int P,int dimP,int indice+1);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement