fork(3) download
  1. #include <stdio.h>
  2. #include <string.h>
  3. void processString(char str[]) {
  4. int firstA = -1, secondA = -1;
  5. for (int i = 0; i < strlen(str); i++) {
  6. if (str[i] == 'A') {
  7. if (firstA == -1) {
  8. firstA = i;
  9. } else {
  10. secondA = i;
  11. break;
  12. }
  13. }
  14. }
  15. if (firstA != -1 && secondA != -1) {
  16. int count = secondA - firstA - 1;
  17. printf("两A中间字符个数: %d\n", count);
  18. for (int i = firstA + 1; i < secondA; i++) {
  19. printf("%c", str[i]);
  20. }
  21. printf("\n");
  22. }
  23. }
  24. int main() {
  25. char str[40];
  26. scanf("%s", str);
  27. processString(str);
  28. return 0;
  29. }
  30.  
Success #stdin #stdout 0s 5324KB
stdin
Standard input is empty
stdout
Standard output is empty