Hi, melinda345.
Could you please help me to understand what you are trying to achieve?
You do not provide any input (string str is declared, but left empty), so what’s the expected output?
I’d also point out:
line 3: -->
using namespace std;
The less you use this instruction, the better.
In this case, find() already exists in std namespace. It's defined in <algorithm>.
You could simply declare:
1 2 3
|
using std::cin;
using std::cout;
using std::endl;
|
line 13 -->
cin>>len;
len is filled with user input... and then neglected.
Also, it should be a good idea to add a std::cout that indicates what input your program is waiting for.
line 31 -->
int i = find(temp);
It’s perfectly legal, but you are aware that you are hiding another “i” variable, are you?
It doesn’t seem to give any problem in this situation, but I’m not sure if it makes your code clearer.
line 4 -->
int find(int a[12]);
When you pass a monodimensional array as the parameter of a function, you are just sending a pointer.
There’s no difference in writing int find(int a[12]) or int find(int* a), apart from the fact that the second better describe the reality. Anyway your code is legal.
Please, add some details to what you aim to do in order to make simpler to help you.