Ты в следующий раз говори, по какому алгоритму это все делается, и заодно приводи в программу те данные, которые заявлены в самом посте...
Я бы делал так:
#include <iostream> #include <conio.h> #include <math.h> using namespace std; char mas[14] = { 2, 1, 2, 1, 3, 1, 4, 0, 4, 0, 4, 0, 4, 0 }; void ToDisplay() { char m[14], m1[8] = {0}; int cnt=0, b = 0, x, i, j=0; for (i=0; i<14; i++) { m[i] = (int)mas[i]; } for (i=0; i<14; ) { x = (int)m[i]; int curr_cnt = (int)m[i+1]; j = i; while((j < 14) && (m[j]==x && m[j+1]==curr_cnt)) { cnt++; cout << "Cnt = " << cnt << endl; j += 2; } cout << x << endl; m1[b++] = x; m1[b++] = cnt * curr_cnt; i += 2*cnt; cnt = 0; } for (i=0; i<8; i++) { cout << (int)m1[i] << " "; } cout << endl; getch(); } int main() { for(int i = 0; i < 14; i++) { cout << (int)mas[i] << " "; } cout << endl; ToDisplay(); getch(); return 0; }