фразу слово все слова
 On-line: гостей 0. Всего: 0 [подробнее..]
Программисты всех стран, объединяйтесь!

АвторСообщение
Отправлено: 15.06.14 10:21. Заголовок: 3 array column comparing and split

int a[]={1,2 ,3,4, 1,1, 6,3 , 1,5,8};
int b[]={2,3 ,8,5, 1,1, 6,3 , 2,6,2};
int c[]={3,7 ,1,2, 2,3, 6,3 , 3,6,1};

i like to split array if column 's are matching high value , mid value , low value based
for example you can see my array first column value a[0] = 1
b[0] = 2
c[0] = 3
first i need to find high value , mid value , low value to do that compare them each other so in this case you can see a[0] = 1 is Low value
b[0] = 2 is the mid value
c[0] = 3 is the high value
then find next column high value , mid value , Low value and compare matching . in this case

a[0] = {1} low value , a[1] = {2} low value
b[0] = {2} mid value , b[1] = {3} mid value
c[0] = {3} high value , c[1] = {7} high value all value are matching . incremented array again find the High , Mid, Low values and so on ...

output i needed

split - 1

1 , 2
2 , 3
3 , 7

split - 2

3 , 4
8 , 5
1 , 2

split - 3

1 , 1
1 , 1
2 , 3

split - 4

6 , 3
6 , 3
6 , 3

split - 5

1,5,8
2,6,2
3,6,1

you can see the last (split -5) is the unmatched value group
i did this code but is a bad code how can i do this in a good way

 Спасибо: 0
Ответов - 9 [только новые]

Отправлено: 15.06.14 22:10. Заголовок: I have not understoo..

I have not understood how you got the ffifth group. You already showed that a column with values

1
2
3

belongs to the first group. So does it mean that two columns that have the same values can belong to two different groups?

As for me then I got the following groups

`  6 3  6 3  6 3    1 1  1 1  2 3    5  6  6    1 2 1  2 3 2  3 7 3    3 4  8 5  1 2    8  2  1  `

The order of the groups depends on the program algorithm that is used.

 Спасибо: 0
Отправлено: 16.06.14 10:38. Заголовок: the 5th group is non..

the 5th group is non-matched column's groups

array are compare based on array high , mid or low matching to next index of the same array high , mid or low
so its not compare array values its compare high , mid ,low that created from the 3array colums
so it mean that two columns that have the same values can belong to two different groups

your using different array show me the array that u using

 Спасибо: 0
Отправлено: 16.06.14 13:06. Заголовок: It seems I have unde..

It seems I have understood. You compare only adjacent columns. So as the result if two columns with values

1
2
3

are separated by an element that does not satisfy the comparisons then they belong to different groups..

In my previous example I grouped all elements together independently whether they are adjacent or not.

 Спасибо: 0
Отправлено: 16.06.14 14:18. Заголовок: use the array that i..

use the array that i used my first question and show me result
i need to group non-matching adjacent columns too

 Спасибо: 0
Отправлено: 16.06.14 14:35. Заголовок: In my previous examp..

In my previous example I used the same arrays as you showed in your first post. Only I grouped them independently whether "equal" elements are adjacent or not. Moreover my groups were sorted starting from the group where all values of a column are equal each other and ending the group where the first value of a column is greater than the second value and the second value is greater than the third value.

You could simplify the task if instead of three arrays you used one array of type std::array<int, 3>.

 Спасибо: 0
Отправлено: 16.06.14 15:25. Заголовок: can u show me the c..

can u show me the code or what are the steps

 Спасибо: 0
Отправлено: 16.06.14 15:50. Заголовок: If you have an objec..

If you have an object of type std::array<int, 3> then you can apply standard algorithm std::adjacent_find to the object according to the criteria.
To deal with one container such as std::array<int, 3> is much simpler than with three separate containers because in the first case you can apply standard algorithms.

 Спасибо: 0
Отправлено: 16.06.14 17:41. Заголовок: i can't use s..

i can't use standard algorithms need other way

 Спасибо: 0
Отправлено: 16.06.14 21:03. Заголовок: It sounds strange be..

It sounds strange because as I said in other your thread standard algorithms are regular template functions. You can of course to write yourself such a function but I do not see any sense.

 Спасибо: 0
Ответ:
1 2 3 4 5 6 7 8 9

показывать это сообщение только модераторам
не делать ссылки активными
Имя, пароль:      зарегистрироваться
 Тему читают:
 - участник сейчас на форуме - участник вне форума Все даты в формате GMT  3 час. Хитов сегодня: 16 Права: смайлы да, картинки да, шрифты да, голосования нет аватары да, автозамена ссылок вкл, премодерация откл, правка нет