|
|
back to boardi dont understand this bug //please help me to solve this problem //my Bug is between the stars. #include <iostream> using namespace std; int main() { int n,s=1; cin >> n; int a[n]; for( int i=0;i<n;i++ ) { cin >> a[i]; } for( int i=0;i<n-1;i++ ) { if( a[i]!=a[i+1] ) s++; } int b[s][2]; for( int i=0;i<s;i++ ) { b[i][1]=-1; b[i][0]=0; } b[0][0]=1; b[0][1]=a[0]; //************************************************************************** for( int i=0; i<n-1;i++ ) { if( a[i]!=a[i+1] ) { int j; for( j=1;j<s;j++ ) { if( b[j][1]=-1 ) break; } b[j][1]=a[i+1]; b[j][0]++; } else if( a[i]==a[i+1] ) { int j; for( j=1;j<s;j++ ) { if( b[j][1]=-1 ) break; } b[j-1][0]++; } } //************************************************************************** for( int i=0;i<s;i++ ) { cout << b[i][0] << " " << b[i][1]<< " "; } return 0; } |
|
|