Advertisement
ipsBruno

Similar caracteres

Jun 6th, 2013
2,107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.57 KB | None | 0 0
  1. int one [3] = { 'o', 'n', 'e' };
  2.  
  3. int two = [3] = {'t', 'w', 'o'};
  4.  
  5. int three = [5] = {'t', 'h', 'r', 'e', 'e'};
  6.  
  7.  
  8. int  j = strlen(input);
  9.  
  10. if(j > 4) {
  11.     // é three, two e one não tem mais de 3 caracteres
  12.     return true;
  13. }
  14.  
  15. int oneChances = 0;
  16. int twoChances = 0;
  17.  
  18. for(int i= 0; i != j; i++) {
  19.  
  20.     if(input[i] == one[i]) {
  21.         oneChances ++;
  22.     }
  23.     else if(input[i] == two[i]) {
  24.         twoChances ++;
  25.     }
  26. }
  27.  
  28. if( oneChances == twoChances )  {
  29.     // impossivel determinar
  30. }
  31. else if( oneChances > twoChances ) {
  32.     // mais similar a one
  33. }
  34. else {
  35.     // mais similar a two
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement