fork download
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5. int check_subsequence (char a[], char b[]) {
  6. int c, d;
  7.  
  8. c = d = 0;
  9.  
  10. while (a[c] != '\0') {
  11. while ((a[c] != b[d]) && b[d] != '\0') {
  12. d++;
  13. }
  14. if (b[d] == '\0')
  15. break;
  16. d++;
  17. c++;
  18. }
  19. if (a[c] == '\0')
  20. return 1;
  21. else
  22. return 0;
  23. }
  24.  
  25. int main(int argc, const char * argv[])
  26. {
  27. printf("%d\n",check_subsequence("67890","67"));
  28. printf("%d\n",check_subsequence("67890","60"));
  29. printf("%d\n",check_subsequence("67890","06"));
  30. printf("%d\n",check_subsequence("67890","67890"));
  31. printf("%d\n",check_subsequence("67890","789"));
  32. printf("%d\n",check_subsequence("67890","90"));
  33. }
  34.  
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
0
0
0
1
0
0