I have corrected the code.It works now.
You may check the changes.
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int counter(int n)
{
int i = 0, j = 0;
char x1 = n / 10 + '0';
char x2 = n % 10 + '0';
char a;
char b;
fstream fisier("bac.txt", fstream::in);
fisier >> b;
while (fisier >> a) {
if (b == x1 && a == x2)
i++;
b = a;
}
return i;
}
int main()
{
int v[101];
int i, maxim = 0, nr;
for (i = 10; i < 100; i++) {
v[i] = counter(i);
if (v[i] > maxim)
maxim = v[i];
}
for (i = 10; i < 100; i++)
if (v[i] == maxim)
cout << i;
}
2
solved Why is my C++ program not working? [closed]