Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- int atm (char *text)
- {
- int i = 0, status = 0;
- for (i; i < strlen (text); i++)
- {
- switch (status)
- {
- case 0 :
- if (text[i] == '-') status = 1;
- break;
- case 1 :
- if (text[i] == '1') status = 2;
- break;
- case 2 :
- if (text[i] == '1') status = 3;
- break;
- case 3 :
- if (text[i] == '-') return 1;
- status = 0;
- break;
- default : break;
- }
- }
- return 0;
- }
- int main()
- {
- printf ("Result: %d\n", atm ("2145412-11-1545154"));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement