fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3. int main()
  4. {
  5. char str[101] = { 0 };
  6. char eng[26] = { 0 };
  7. char result[26] = { 0 };
  8.  
  9. scanf("%s", str);
  10.  
  11. for (int i = 0; i < 26; i++) {
  12. eng[i] = (97 + i);
  13. result[i] = -1;
  14. }
  15. for (int i = 0; i < strlen(str); i++)
  16. {
  17. for (int j = 0; j < 26; j++)
  18. {
  19. if (str[i] == str[i + j + 1])
  20. str[i + j + 1] = -1;
  21. if (str[i] == eng[j])
  22. result[j] = i;
  23. }
  24. }
  25. for (int i = 0; i < 26; i++)
  26. {
  27. printf("%d ", result[i]);
  28. }
  29. }
Success #stdin #stdout 0s 4236KB
stdin
abbbbbbbbbbbbbbbbbbbbbbbbbba
stdout
27 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1