#include <iostream>
#include <conio.h>
#include <math.h>
using namespace std;
char mas[16];
void ToDisplay()
{ char m[16],m1[8];
int cnt=0, b= 0, x,i,j=0;
for (i=0; i<16; i++)
m[i]=(int)mas[i];
for (i=0; i<16; i+=2)
{
x=(int)m[i];
while(j<16)
{
cout<<x<<endl;
cout<<(int)m[j]<<endl;
cout<<(int)m[j+1]<<endl;
if ((m[j]==x)&&(m[j+1]==1))
{
cnt++; // <--- !!!
cout<<"Cnt = "<<cnt<<endl;
break;
}
j+=2;
}
m1[b]=x;
m1[b+1]=cnt;
b+=2;
cnt=0;
}
for (i=0; i<8; i++)
{
cout<<(int)m1[i]<<" ";
}
cout<<endl;
getch();
}
int main()
{
mas[0]=2;
mas[1]=1;
mas[2]=2;
mas[3]=1;
mas[4]=3;
mas[5]=1;
mas[6]=3;
mas[7]=0;
mas[8]=4;
mas[9]=0;
mas[10]=4;
mas[11]=0;
mas[12]=4;
mas[13]=0;
mas[14]=4;
mas[15]=0;
for(int i=0;i<16;i++)
{
cout<<(int)mas[i]<<" ";
}
cout<<endl;
ToDisplay();
getch();
}
Помогите найти ошибку, C++ |