#include <iostream>
#include <fstream>
usingnamespace std;
int Comp(ifstream archive, int number, int ant, int qtd){
while(archive >> number){
if (number == 2*ant){
qtd++;
}
ant = number;
}
archive.close();
return qtd;
}
int main(){
int number, qtd = 0;
int ant = -1;
ifstream archive("numbers.txt");
int i = Comp (archive, number, ant, qtd);
return 0;
}
And, this code receive a archive with some numbers. So, this algorithm tells me how many numbers have your previous number = him/2;
*If* you can modify your function prototype, perhaps the simplest method is changing it from int Comp(std::ifstream archive, int number, int ant, int qtd)
to int Comp(std::ifstream& archive, int number, int ant, int qtd)