Demlo number ( Square of 11. . .1 ) | CPP program to print DemloNumber ; To return demlo number . This function assumes that the length of str is smaller than 10. ; Add numbers to res upto size of str and then add number reverse to it ; Driver program to test printDemlo ( )
#include <bits/stdc++.h> NEW_LINE using namespace std ; string printDemlo ( string str ) { int len = str . length ( ) ; string res = " " ; for ( int i = 1 ; i <= len ; i ++ ) res += char ( i + '0' ) ; for ( int i = len - 1 ; i >= 1 ; i -- ) res += char ( i + '0' ) ; return res ; } int main ( ) { string str = "111111" ; cout << printDemlo ( str ) ; return 0 ; }