#include
using namespace std;
void judge(int bb[15]);
void input(char str[15]);
char str[15];
char x;
int bb[15];
int a, c, d;
main()
{ input (str);
judge (bb);
system("pause");
}
void input(char str[15])
{ cout << "请输入字符串" << endl;
cin >> str;
cout << "请输入需要查找的元素" << endl;
cin >> x;
}
void judge(int bb[15])
{ c = 0;
for (a = 0; a < 15; a++)
{ if (str[a] == x)
bb[c++] = a;
}
cout << "一共有" << c << "个所查找的元素" << endl;
cout << "下标依次为";
for (d = 0; d < c; d++)
{ cout << bb[d] << " ";
}
}
不知道是dos下的还是windows下的
将judge函数改如下——