codeparrot/xlcost-text-to-code huggingface dataset:
Split numeric , alphabetic and special symbols from a String | CPP program to split an alphanumeric string using STL ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; void splitString ( string str ) { string alpha , num , special ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( isdigit ( str [ i ] ) ) num . push_back ( str [ i ] ) ; else if ( ( str [ i ] >= ' A ' && str [ i ] <= ' Z ' ) || ( str [ i ] >= ' a ' && str [ i ] <= ' z ' ) ) alpha . push_back ( str [ i ] ) ; else special . push_back ( str [ i ] ) ; } cout << alpha << endl ; cout << num << endl ; cout << special << endl ; } int main ( ) { string str = " geeks01 $ $ for02geeks03 ! @ ! ! " ; splitString ( str ) ; return 0 ; }
Program to print all substrings of a given string | C ++ program to print all possible substrings of a given string ; Function to print all sub strings ; Pick starting point in outer loop and lengths of different strings for a given starting point ; Driver program to test above function
#include <bits/stdc++.h> NEW_LINE using namespace std ; void subString ( string s , int n ) { for ( int i = 0 ; i < n ; i ++ ) for ( int len = 1 ; len <= n - i ; len ++ ) cout << s . substr ( i , len ) << endl ; } int main ( ) { string s = " abcd " ; subString ( s , s . length ( ) ) ; return 0 ; }
Program to print all substrings of a given string | CPP program for the above approach ; finding the length of the string ; outermost for loop this is for the selection of starting point ; 2 nd for loop is for selection of ending point ; 3 rd loop is for printing from starting point to ending point ; changing the line after printing from starting point to ending point ; Driver Code ; calling method for printing substring
#include <iostream> NEW_LINE using namespace std ; void printSubstrings ( string str ) { int n = str . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i ; j < n ; j ++ ) { for ( int k = i ; k <= j ; k ++ ) { cout << str [ k ] ; } cout << endl ; } } } int main ( ) { string str = " abcd " ; printSubstrings ( str ) ; return 0 ; }
Maximum Tip Calculator | C ++ implementation of the approach ; Recursive function to calculate sum of maximum tip order taken by X and Y ; When all orders have been taken ; When X cannot take more orders ; When Y cannot take more orders ; When both can take order calculate maximum out of two ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int n ; int solve ( int i , int X , int Y , int a [ ] , int b [ ] , int n ) { if ( i == n ) return 0 ; if ( X <= 0 ) return b [ i ] + solve ( i + 1 , X , Y - 1 , a , b , n ) ; if ( Y <= 0 ) return a [ i ] + solve ( i + 1 , X - 1 , Y , a , b , n ) ; else return max ( a [ i ] + solve ( i + 1 , X - 1 , Y , a , b , n ) , b [ i ] + solve ( i + 1 , X , Y - 1 , a , b , n ) ) ; } int main ( ) { int a [ ] = { 1 , 2 , 3 , 4 , 5 } ; int b [ ] = { 5 , 4 , 3 , 2 , 1 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; int x = 3 , y = 3 ; cout << solve ( 0 , x , y , a , b , n ) ; return 0 ; }
Number of even substrings in a string of digits | C ++ program to count number of substring which are even integer in a string of digits . ; Return the even number substrings . ; If current digit is even , add count of substrings ending with it . The count is ( i + 1 ) ; Driven Program
#include <bits/stdc++.h> NEW_LINE using namespace std ; int evenNumSubstring ( char str [ ] ) { int len = strlen ( str ) ; int count = 0 ; for ( int i = 0 ; i < len ; i ++ ) { int temp = str [ i ] - '0' ; if ( temp % 2 == 0 ) count += ( i + 1 ) ; } return count ; } int main ( ) { char str [ ] = "1234" ; cout << evenNumSubstring ( str ) << endl ; return 0 ; }
Maximum Consecutive Increasing Path Length in Binary Tree | C ++ Program to find Maximum Consecutive Path Length in a Binary Tree ; To represent a node of a Binary Tree ; Create a new Node and return its address ; Returns the maximum consecutive Path Length ; Get the value of Current Node The value of the current node will be prev Node for its left and right children ; If current node has to be a part of the consecutive path then it should be 1 greater than the value of the previous node ; a ) Find the length of the Left Path b ) Find the length of the Right Path Return the maximum of Left path and Right path ; Find length of the maximum path under subtree rooted with this node ( The path may or may not include this node ) ; Take the maximum previous path and path under subtree rooted with this node . ; A wrapper over maxPathLenUtil ( ) . ; Return 0 if root is NULL ; Else compute Maximum Consecutive Increasing Path Length using maxPathLenUtil . ; Driver program to test above function
#include <bits/stdc++.h> NEW_LINE using namespace std ; struct Node { Node * left , * right ; int val ; } ; Node * newNode ( int val ) { Node * temp = new Node ( ) ; temp -> val = val ; temp -> left = temp -> right = NULL ; return temp ; } int maxPathLenUtil ( Node * root , int prev_val , int prev_len ) { if ( ! root ) return prev_len ; int cur_val = root -> val ; if ( cur_val == prev_val + 1 ) { return max ( maxPathLenUtil ( root -> left , cur_val , prev_len + 1 ) , maxPathLenUtil ( root -> right , cur_val , prev_len + 1 ) ) ; } int newPathLen = max ( maxPathLenUtil ( root -> left , cur_val , 1 ) , maxPathLenUtil ( root -> right , cur_val , 1 ) ) ; return max ( prev_len , newPathLen ) ; } int maxConsecutivePathLength ( Node * root ) { if ( root == NULL ) return 0 ; return maxPathLenUtil ( root , root -> val - 1 , 0 ) ; } int main ( ) { Node * root = newNode ( 10 ) ; root -> left = newNode ( 11 ) ; root -> right = newNode ( 9 ) ; root -> left -> left = newNode ( 13 ) ; root -> left -> right = newNode ( 12 ) ; root -> right -> left = newNode ( 13 ) ; root -> right -> right = newNode ( 8 ) ; cout << " Maximum ▁ Consecutive ▁ Increasing ▁ Path ▁ Length ▁ is ▁ " << maxConsecutivePathLength ( root ) ; return 0 ; }
Find largest word in dictionary by deleting some characters of given string | C ++ program to find largest word in Dictionary by deleting some characters of given string ; Returns true if str1 [ ] is a subsequence of str2 [ ] . m is length of str1 and n is length of str2 ; Traverse str2 and str1 , and compare current character of str2 with first unmatched char of str1 , if matched then move ahead in str1 ; If all characters of str1 were found in str2 ; Returns the longest string in dictionary which is a subsequence of str . ; Traverse through all words of dictionary ; If current word is subsequence of str and is largest such word so far . ; Return longest string ; Driver program to test above function
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool isSubSequence ( string str1 , string str2 ) { int m = str1 . length ( ) , n = str2 . length ( ) ; for ( int i = 0 ; i < n && j < m ; i ++ ) if ( str1 [ j ] == str2 [ i ] ) j ++ ; return ( j == m ) ; } string findLongestString ( vector < string > dict , string str ) { string result = " " ; int length = 0 ; for ( string word : dict ) { if ( length < word . length ( ) && isSubSequence ( word , str ) ) { result = word ; length = word . length ( ) ; } } return result ; } int main ( ) { vector < string > dict = { " ale " , " apple " , " monkey " , " plea " } ; string str = " abpcplea " ; cout << findLongestString ( dict , str ) << endl ; return 0 ; }
Count of distinct substrings of a string using Suffix Trie | A C ++ program to find the count of distinct substring of a string using trie data structure ; A Suffix Trie ( A Trie of all suffixes ) Node ; SuffixTrieNode ( ) Constructor ; Initialize all child pointers as NULL ; A recursive function to insert a suffix of the s in subtree rooted with this node ; If string has more characters ; Find the first character and convert it into 0 - 25 range . ; If there is no edge for this character , add a new edge ; Recur for next suffix ; A Trie of all suffixes ; Constructor ( Builds a trie of suffies of the given text ) ; Consider all suffixes of given string and insert them into the Suffix Trie using recursive function insertSuffix ( ) in SuffixTrieNode class ; A recursive function to count nodes in trie ; If all characters of pattern have been processed , ; if children is not NULL then find count of all nodes in this subtrie ; return count of nodes of subtrie and plus 1 because of node 's own count ; method to count total nodes in suffix trie ; Returns count of distinct substrings of str ; Construct a Trie of all suffixes ; Return count of nodes in Trie of Suffixes ; Driver program to test above function
#include <bits/stdc++.h> NEW_LINE #define MAX_CHAR  26 NEW_LINE using namespace std ; class SuffixTrieNode { public : SuffixTrieNode * children [ MAX_CHAR ] ; { for ( int i = 0 ; i < MAX_CHAR ; i ++ ) children [ i ] = NULL ; } void SuffixTrieNode :: insertSuffix ( string s ) { if ( s . length ( ) > 0 ) { char cIndex = s . at ( 0 ) - ' a ' ; if ( children [ cIndex ] == NULL ) children [ cIndex ] = new SuffixTrieNode ( ) ; children [ cIndex ] -> insertSuffix ( s . substr ( 1 ) ) ; } } class SuffixTrie { SuffixTrieNode * root ; int _countNodesInTrie ( SuffixTrieNode * ) ; public : SuffixTrie ( string s ) { root = new SuffixTrieNode ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) root -> insertSuffix ( s . substr ( i ) ) ; } int SuffixTrie :: _countNodesInTrie ( SuffixTrieNode * node ) { if ( node == NULL ) return 0 ; int count = 0 ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) { if ( node -> children [ i ] != NULL ) count += _countNodesInTrie ( node -> children [ i ] ) ; } return ( 1 + count ) ; } int countNodesInTrie ( ) { return _countNodesInTrie ( root ) ; } } ; int countDistinctSubstring ( string str ) { SuffixTrie sTrie ( str ) ; return sTrie . countNodesInTrie ( ) ; } int main ( ) { string str = " ababa " ; cout << " Count ▁ of ▁ distinct ▁ substrings ▁ is ▁ " << countDistinctSubstring ( str ) ; return 0 ; }
XOR Cipher | C ++ program to implement XOR - Encryption ; The same function is used to encrypt and decrypt ; Define XOR key Any character value will work ; calculate length of input string ; perform XOR operation of key with every character in string ; Driver program to test above function ; Encrypt the string ; Decrypt the string
#include <bits/stdc++.h> NEW_LINE void encryptDecrypt ( char inpString [ ] ) { char xorKey = ' P ' ; int len = strlen ( inpString ) ; for ( int i = 0 ; i < len ; i ++ ) { inpString [ i ] = inpString [ i ] ^ xorKey ; printf ( " % c " , inpString [ i ] ) ; } } int main ( ) { char sampleString [ ] = " GeeksforGeeks " ; printf ( " Encrypted ▁ String : ▁ " ) ; encryptDecrypt ( sampleString ) ; printf ( " STRNEWLINE " ) ; printf ( " Decrypted ▁ String : ▁ " ) ; encryptDecrypt ( sampleString ) ; return 0 ; }
Compare two Version numbers | C / C ++ program to compare two version number ; Method to compare two versions . Returns 1 if v2 is smaller , - 1 if v1 is smaller , 0 if equal ; vnum stores each numeric part of version ; loop until both string are processed ; storing numeric part of version 1 in vnum1 ; storing numeric part of version 2 in vnum2 ; if equal , reset variables and go for next numeric part ; Driver method to check above comparison function
#include <bits/stdc++.h> NEW_LINE using namespace std ; int versionCompare ( string v1 , string v2 ) { int vnum1 = 0 , vnum2 = 0 ; for ( int i = 0 , j = 0 ; ( i < v1 . length ( ) || j < v2 . length ( ) ) ; ) { while ( i < v1 . length ( ) && v1 [ i ] != ' . ' ) { vnum1 = vnum1 * 10 + ( v1 [ i ] - '0' ) ; i ++ ; } while ( j < v2 . length ( ) && v2 [ j ] != ' . ' ) { vnum2 = vnum2 * 10 + ( v2 [ j ] - '0' ) ; j ++ ; } if ( vnum1 > vnum2 ) return 1 ; if ( vnum2 > vnum1 ) return -1 ; vnum1 = vnum2 = 0 ; i ++ ; j ++ ; } return 0 ; } int main ( ) { string version1 = "1.0.3" ; string version2 = "1.0.7" ; if ( versionCompare ( version1 , version2 ) < 0 ) cout << version1 << " ▁ is ▁ smaller STRNEWLINE " ; else if ( versionCompare ( version1 , version2 ) > 0 ) cout << version2 << " ▁ is ▁ smaller STRNEWLINE " ; else cout << " Both ▁ version ▁ are ▁ equal STRNEWLINE " ; return 0 ; }
Repeated subsequence of length 2 or more | C ++ program to check if any repeated subsequence exists in the string ; A function to check if a string str is palindrome ; l and h are leftmost and rightmost corners of str Keep comparing characters while they are same ; The main function that checks if repeated subsequence exists in the string ; Find length of input string ; Create an array to store all characters and their frequencies in str [ ] ; Traverse the input string and store frequencies of all characters in freq [ ] array . ; If the character count is more than 2 we found a repetition ; In - place remove non - repeating characters from the string ; check if the resultant string is palindrome ; special case - if length is odd return true if the middle character is same as previous one ; return false if string is a palindrome ; return true if string is not a palindrome ; Driver code
#include <bits/stdc++.h> NEW_LINE #define MAX_CHAR  256 NEW_LINE using namespace std ; bool isPalindrome ( char str [ ] , int l , int h ) { while ( h > l ) if ( str [ l ++ ] != str [ h -- ] ) return false ; return true ; } int check ( char str [ ] ) { int n = strlen ( str ) ; int freq [ MAX_CHAR ] = { 0 } ; for ( int i = 0 ; i < n ; i ++ ) { freq [ str [ i ] ] ++ ; if ( freq [ str [ i ] ] > 2 ) return true ; } int k = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( freq [ str [ i ] ] > 1 ) str [ k ++ ] = str [ i ] ; str [ k ] = ' \0' ; if ( isPalindrome ( str , 0 , k - 1 ) ) { if ( k & 1 ) return str [ k / 2 ] == str [ k / 2 - 1 ] ; return false ; } return true ; } int main ( ) { char str [ ] = " ABCABD " ; if ( check ( str ) ) cout << " Repeated ▁ Subsequence ▁ Exists " ; else cout << " Repeated ▁ Subsequence ▁ Doesn ' t ▁ Exists " ; return 0 ; }
How to find Lexicographically previous permutation ? | C ++ program to print all permutations with duplicates allowed using prev_permutation ( ) ; Function to compute the previous permutation ; Find index of the last element of the string ; Find largest index i such that str [ i - 1 ] > str [ i ] ; if string is sorted in ascending order we 're at the last permutation ; Note - str [ i . . n ] is sorted in ascending order . Find rightmost element 's index that is less  than str[i - 1] ; Swap character at i - 1 with j ; Reverse the substring [ i . . n ] ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool prevPermutation ( string & str ) { int n = str . length ( ) - 1 ; int i = n ; while ( i > 0 && str [ i - 1 ] <= str [ i ] ) i -- ; if ( i <= 0 ) return false ; int j = i - 1 ; while ( j + 1 <= n && str [ j + 1 ] < str [ i - 1 ] ) j ++ ; swap ( str [ i - 1 ] , str [ j ] ) ; reverse ( str . begin ( ) + i , str . end ( ) ) ; return true ; } int main ( ) { string str = "4321" ; if ( prevPermutation ( str ) ) cout << " Previous ▁ permutation ▁ is ▁ " << str ; else cout << " Previous ▁ permutation ▁ doesn ' t ▁ exist " ; return 0 ; }
Longest Path with Same Values in a Binary Tree | C ++ program to find the length of longest path with same values in a binary tree . ; A binary tree node has data , pointer to left child and a pointer to right child ; Function to print the longest path of same values ; Recursive calls to check for subtrees ; Variables to store maximum lengths in two directions ; If curr node and it 's left child has same value ; If curr node and it 's right child has same value ; Driver function to find length of longest same value path ; Helper function that allocates a new node with the given data and NULL left and right pointers . ; Driver code ; Let us construct a Binary Tree 4 / \ 4 4 / \ \ 4 9 5
#include <bits/stdc++.h> NEW_LINE using namespace std ; struct Node { int val ; struct Node * left , * right ; } ; int length ( Node * node , int * ans ) { if ( ! node ) return 0 ; int left = length ( node -> left , ans ) ; int right = length ( node -> right , ans ) ; int Leftmax = 0 , Rightmax = 0 ; if ( node -> left && node -> left -> val == node -> val ) Leftmax += left + 1 ; if ( node -> right && node -> right -> val == node -> val ) Rightmax += right + 1 ; * ans = max ( * ans , Leftmax + Rightmax ) ; return max ( Leftmax , Rightmax ) ; } int longestSameValuePath ( Node * root ) { int ans = 0 ; length ( root , & ans ) ; return ans ; } Node * newNode ( int data ) { Node * temp = new Node ; temp -> val = data ; temp -> left = temp -> right = NULL ; return temp ; } int main ( ) { Node * root = NULL ; root = newNode ( 4 ) ; root -> left = newNode ( 4 ) ; root -> right = newNode ( 4 ) ; root -> left -> left = newNode ( 4 ) ; root -> left -> right = newNode ( 9 ) ; root -> right -> right = newNode ( 5 ) ; cout << longestSameValuePath ( root ) ; return 0 ; }
Check if edit distance between two strings is one | C ++ program to check if given two strings are at distance one . ; Returns true if edit distance between s1 and s2 is one , else false ; Find lengths of given strings ; If difference between lengths is more than 1 , then strings can 't be at one distance ; int count = 0 ; Count of edits ; If current characters don 't match ; If length of one string is more , then only possible edit is to remove a character ; else Iflengths of both strings is same ; Increment count of edits ; else If current characters match ; If last character is extra in any string ; Driver program
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool isEditDistanceOne ( string s1 , string s2 ) { int m = s1 . length ( ) , n = s2 . length ( ) ; if ( abs ( m - n ) > 1 ) return false ; int i = 0 , j = 0 ; while ( i < m && j < n ) { if ( s1 [ i ] != s2 [ j ] ) { if ( count == 1 ) return false ; if ( m > n ) i ++ ; else if ( m < n ) j ++ ; { i ++ ; j ++ ; } count ++ ; } { i ++ ; j ++ ; } } if ( i < m j < n ) count ++ ; return count == 1 ; } int main ( ) { string s1 = " gfg " ; string s2 = " gf " ; isEditDistanceOne ( s1 , s2 ) ? cout << " Yes " : cout << " No " ; return 0 ; }
Count of numbers from range [ L , R ] whose sum of digits is Y | Set 2 | CPP program for the above approach ; Function to find the sum of digits of numbers in the range [ 0 , X ] ; Check if count of digits in a number greater than count of digits in X ; If sum of digits of a number is equal to Y ; Check if current subproblem has already been computed ; Stores count of numbers whose sum of digits is Y ; Check if the number exceeds Y or not ; Iterate over all possible values of i - th digits ; Update res ; Return res ; Utility function to count the numbers in the range [ L , R ] whose sum of digits is Y ; Base Case ; Stores numbers in the form of its equivalent string ; Stores overlapping subproblems ; Initialize dp [ ] [ ] [ ] ; Stores count of numbers in the range [ 0 , R ] ; Update str ; Initialize dp [ ] [ ] [ ] ; Stores count of numbers in the range [ 0 , L - 1 ] ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; #define M  1000 NEW_LINE int cntNum ( string X , int i , int sum , int tight , int dp [ M ] [ M ] [ 2 ] ) { if ( i >= X . length ( ) sum < 0 ) { if ( sum == 0 ) { return 1 ; } return 0 ; } if ( dp [ sum ] [ i ] [ tight ] != -1 ) { return dp [ sum ] [ i ] [ tight ] ; } int res = 0 ; int end = tight ? X [ i ] - '0' : 9 ; for ( int j = 0 ; j <= end ; j ++ ) { res += cntNum ( X , i + 1 , sum - j , ( tight & ( j == end ) ) , dp ) ; } return dp [ sum ] [ i ] [ tight ] = res ; } int UtilCntNumRange ( int L , int R , int Y ) { if ( R == 0 && Y == 0 ) { return 1 ; } string str = to_string ( R ) ; int dp [ M ] [ M ] [ 2 ] ; memset ( dp , -1 , sizeof ( dp ) ) ; int cntR = cntNum ( str , 0 , Y , true , dp ) ; str = to_string ( L - 1 ) ; memset ( dp , -1 , sizeof ( dp ) ) ; int cntL = cntNum ( str , 0 , Y , true , dp ) ; return ( cntR - cntL ) ; } int main ( ) { int L = 20 , R = 10000 , Y = 14 ; cout << UtilCntNumRange ( L , R , Y ) ; }
Remove spaces from a given string | CPP program to Remove spaces from a given string ; Function to remove all spaces from a given string ; Driver program to test above function
#include <iostream> NEW_LINE #include <algorithm> NEW_LINE using namespace std ; string removeSpaces ( string str ) { str . erase ( remove ( str . begin ( ) , str . end ( ) , ' ▁ ' ) , str . end ( ) ) ; return str ; } int main ( ) { string str = " g ▁ eeks ▁ for ▁ ge ▁ eeks ▁ " ; str = removeSpaces ( str ) ; cout << str ; return 0 ; }
Given a binary string , count number of substrings that start and end with 1. | A simple C ++ program to count number of substrings starting and ending with 1 ; Initialize result ; Pick a starting point ; Search for all possible ending point ; Driver program to test above function
#include <iostream> NEW_LINE using namespace std ; int countSubStr ( char str [ ] ) { int res = 0 ; for ( int i = 0 ; str [ i ] != ' \0' ; i ++ ) { if ( str [ i ] == '1' ) { for ( int j = i + 1 ; str [ j ] != ' \0' ; j ++ ) if ( str [ j ] == '1' ) res ++ ; } } return res ; } int main ( ) { char str [ ] = "00100101" ; cout << countSubStr ( str ) ; return 0 ; }
An in | C ++ implementation of above approach ; A utility function to swap characters ; A utility function to reverse string str [ low . . high ] ; Cycle leader algorithm to move all even positioned elements at the end . ; odd index ; even index ; keep the back - up of element at new position ; The main function to transform a string . This function mainly uses cycleLeader ( ) to transform ; Step 1 : Find the largest prefix subarray of the form 3 ^ k + 1 ; Step 2 : Apply cycle leader algorithm for the largest subarrau ; Step 4.1 : Reverse the second half of first subarray ; Step 4.2 : Reverse the first half of second sub - string . ; Step 4.3 Reverse the second half of first sub - string and first half of second sub - string together ; Increase the length of first subarray ; Driver program to test above function
#include <bits/stdc++.h> NEW_LINE using namespace std ; void swap ( char * a , char * b ) { char t = * a ; * a = * b ; * b = t ; } void reverse ( char * str , int low , int high ) { while ( low < high ) { swap ( & str [ low ] , & str [ high ] ) ; ++ low ; -- high ; } } void cycleLeader ( char * str , int shift , int len ) { int j ; char item ; for ( int i = 1 ; i < len ; i *= 3 ) { j = i ; item = str [ j + shift ] ; do { if ( j & 1 ) j = len / 2 + j / 2 ; else j /= 2 ; swap ( & str [ j + shift ] , & item ) ; } while ( j != i ) ; } } void moveNumberToSecondHalf ( char * str ) { int k , lenFirst ; int lenRemaining = strlen ( str ) ; int shift = 0 ; while ( lenRemaining ) { k = 0 ; while ( pow ( 3 , k ) + 1 <= lenRemaining ) k ++ ; lenFirst = pow ( 3 , k - 1 ) + 1 ; lenRemaining -= lenFirst ; cycleLeader ( str , shift , lenFirst ) ; reverse ( str , shift / 2 , shift - 1 ) ; reverse ( str , shift , shift + lenFirst / 2 - 1 ) ; reverse ( str , shift / 2 , shift + lenFirst / 2 - 1 ) ; shift += lenFirst ; } } int main ( ) { char str [ ] = " a1b2c3d4e5f6g7" ; moveNumberToSecondHalf ( str ) ; cout << str ; return 0 ; }