Advertisement
Guest User

Untitled

a guest
Apr 21st, 2015
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.71 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int atm (char *text)
  5. {
  6.     int i = 0, status = 0;
  7.     for (i; i < strlen (text); i++)
  8.     {
  9.         switch (status)
  10.         {
  11.             case 0 :
  12.                 if (text[i] == '-') status = 1;
  13.             break;
  14.             case 1 :
  15.                 if (text[i] == '1') status = 2;
  16.             break;
  17.             case 2 :
  18.                 if (text[i] == '1') status = 3;
  19.             break;
  20.             case 3 :
  21.                 if (text[i] == '-') return 1;
  22.                 status = 0;
  23.             break;
  24.             default : break;
  25.         }
  26.     }
  27.     return 0;
  28. }
  29.  
  30. int main()
  31. {
  32.     printf ("Result: %d\n", atm ("2145412-11-1545154"));
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement