Advertisement
Guest User

Untitled

a guest
Mar 4th, 2015
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void tokenize (char * source, char ** tokens, int & size_of_tokens)
  5. {
  6.     char * token = strtok(source, " ,.!?:-\\\t");
  7.     int size = 0;
  8.     while (token)
  9.     {
  10.         bool found = false;
  11.         for (size_t i=0; i<size; i++)
  12.         {
  13.             if (strcmp(token,tokens[i]) == 0)
  14.                 found = true;  
  15.         }
  16.         if (!found)
  17.         {
  18.             strcpy (tokens[size], token);
  19.             size++;
  20.         }
  21.         token = strtok(NULL, " ,.!?:-\\\t");
  22.     }
  23.     size_of_tokens = size;
  24. }
  25.  
  26. int common_symb_in_order_cnt (char * str1, char * str2, size_t len)
  27. {
  28.     int cnt = 0;
  29.     for (int i=0; i<len; i++)
  30.     {
  31.         if (str1[i]==str2[i])
  32.             cnt++;
  33.     }
  34.     return cnt;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement