hello everyone, hope all of u are fine..
i have a problem in my work. i have a data in a .txt file format.
the data is looks like below :
4 5 4 4 1
6 4 4 3 3 2 0
2 3 1
6 8 4 4 2 1 1 figure 1
12 8 8 7 7 5 5 3 3 1 1 0 0
6 7 7 6 4 4 0
2 7 5
6 8 6 5 5 4 4
4 7 4 4 3
the leftmost value will be determine how many number in this column.For instance, first row, the leftmost value is 4, then there are 4 numbers after it.
same goes to rest.
u guys can see there are duplicated numbers and want i want to do is, to delete the duplicated value, and takes only one value like below:
5 4 1
4 3 2 0
3 1
8 4 2 1
8 7 5 3 1 0 figure 2
7 6 4 0
7 5
8 6 5 4 4
4 7 4 3
and i don't want to take the leftmost (figure 1)value anymore..
i have try to code this idea, maybe anyone can help me to figure out what why it become like this??
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
void readdata2()
{
ifstream infile;
infile.open("neighbor.txt");
for(int i=0;i<noofvert;i++)
{
// cout << m[i] ;
for(int j=1;j<m[i];j++)
{
cout << num[j];
for(int k=0;k<m[i]-1;k++)
{
if(num[k] == num[k+1])
num[k+1] = num[k];
else
num[k] = num[k+1];
}
}
//cout << endl;
}
|
i hope, u can help me..thank you very much...