Advertisement
Guest User

numero sottostringhe

a guest
Nov 14th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.  
  8.   int vet[23]={23,45,21,33,12,33,22,44,66,45,21,33,12,11,8,7,6,11,45,21,33,12,13};
  9.   int s1[4]={45,21,33,12};
  10.   int n=23;
  11.   int m=4;
  12.   int i=0;
  13.   int j=0;
  14.   int cont=0;
  15.   bool trovato=true;
  16.   while(i<n){
  17.       if(vet[i]==s1[j]){
  18.           while(j<m && trovato==true){
  19.               if(vet[i]!=s1[j]){
  20.                   trovato=false;
  21.               }
  22.               j++;
  23.               i++;
  24.             }
  25.         if(trovato==true)
  26.               cont++;
  27.         j=0;
  28.         trovato=true;  
  29.       }
  30.     i++;
  31.   }
  32.  cout<<cont;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement