#include
using namespace std;
int count = 0, cache[50];
int f(int n)
{
if(n == 2) count++;
if(n == 0 || n==1) return n;
else if (ca
I think I may have figured this out. I have found that removing the using namespace std
doesn't help, but when I change the name of the variable to something which is less common, like count can be changed to cnt
or some personal versions like knt
or isCycle
. I don't exactly know what is the reason behind this.
yeah idk but changing the name to less common variable name works fine in case of mine
The problem is all because of the second line here:
#include <algorithm>
using namespace std;
The line using namespace std
brings all the names from <algorithm>
which also has a function called count
, and in your code, you've declared a variable count
. Hence the ambiguous error.
The solution is to never write using namespace std
. It is bad bad bad.
Instead, use std::cout
, std::cin
, std::endl
, std::count
and so on, in your code.