Binary String of given length that without a palindrome of size 3 | CPP program find a binary string of given length that doesn 't contain a palindrome of size 3. ; Printing the character according to i ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; void generatestring ( int n ) { for ( int i = 0 ; i < n ; i ++ ) putchar ( i & 2 ? ' b ' : ' a ' ) ; puts ( " " ) ; } int main ( ) { int n = 5 ; generatestring ( n ) ; n = 8 ; generatestring ( n ) ; n = 10 ; generatestring ( n ) ; }