1234567891011121314151617181920212223242526272829303132333435363738 |
- #include <stdio.h>
- #include <string.h>
- int main() {
- int i;
- char str[100], ch;
- int count[100], flag = 0, len;
- fgets(str, sizeof(str), stdin);
- scanf("%c", &ch);
- len = strlen(str);
- int index = 0;
- for (i = 0; i < len; ++i) {
- if (str[i] == ch) {
- count[index++] = i;
- flag = 1;
- }
- }
- count[index] = '\0';
- if (flag) {
- printf("%d\n", index);
- for (i = 0; i < index; ++i) {
- printf("%d", count[i]);
- if (i < index - 1) {
- printf("#");
- }
- }
- printf("#\n");
- } else {
- printf("No match\n");
- }
- return 0;
- }
|