Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3. using namespace std;
  4.  
  5. int main() {
  6.     int n, i;
  7.     int const MAX_PAROLA = 100;
  8.     char prima_parola[MAX_PAROLA+1], parola_generica[MAX_PAROLA+1];
  9.     int occorrenze;
  10.  
  11.     cin >> prima_parola;
  12.     cin >> n;
  13.     occorrenze = 0;
  14.  
  15.     for(i=0;i<n;i++)
  16.         cin>>parola_generica[i];
  17.  
  18.     for(i=0;i<n;i++){
  19.      if ( !strcmp(prima_parola, parola_generica[i]) ) // se sono uguali
  20.      occorrenze++;
  21.     }
  22.     cout << "Il numero di occorrenze e’: " << occorrenze << endl;
  23.  
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement