1
First I have a struct
strcuct Ficha{
int resgistro;
float pontuacao;
}Fichas[100];
is the following I will read random mode data, but a data always in the list will start with the number that is not integer on pointing
0.5//pontuação
89933//registro
49494
0.4
87474
0.6
89044
88443
86965
The problem is the following 0.5 is of the two record that comes down, 0.4 is only 87474 and then comes 0.6 that belongs to the record that you have below the score this is the logic.
Good as data is in a file txt
Reading
void lerArquvivo(){
ifstream Arquivo;
Arquivo.open("Regeistro.txt");
char linha[10];
float n;
while(Arquivo.getline(linha,10)){
Arquivo >> n;
separa(n);
}
Arquivo.close();
}
Then create a function that separates integer from non-integer.
void separa(floar valor){
int x = valor;
float y = valor;
if(x==y){
//cout<<"Inteiro"<<endl;
}else{
//cout<<"Não e Inteiro"<<endl;
}
}
Here it comes, as I have to store in vector Chips Fichas[i].registro
and Fichas[i].pontuacao
, i can’t do to store in the numbers of the related vector position.
As an example of the problem.
posição do vetor registro pontuação
0 0 0.5
1 89487 0
2 78474 0
3 0 0.4
.
.......
Please avoid long discussions in the comments; your talk was moved to the chat
– Maniero