- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7347 Articles for C++
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
277 Views
We are given a string type variable, let's say, str which will be used to store the source code then calculate the size of the string and pass it to the function. The task is to rearrange the given source code and then print the result.Let us see various input output scenarios for this −Input − string str ="#include using namespace std; int main()" "{ int sum, first, second; sum = first + second; printf(\"%d\", c);" " return 0;}"Output −#include using namespace std; int main(){ int sum, first, second; sum = first + second; printf("%d", ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
218 Views
We are given with a string ‘str’ of any given length. The task is to rearrange the characters in such a manner that there will be maximum substrings that will be a palindrome string without adding or removing a character from the given input string. Palindrome string is the one in which the characters are arranged in such a manner that they pronounce the same from start and last.Let us see various input output scenarios for this −Input − string str = "itnin"Output − Rearrangement of the string to maximize the number of palindromic substrings is: iinnt.Explanation − We are given a string ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
272 Views
We are given an integer type number, let's say, number. The task is to rearrange number digit’s in such a manner that a number formed after rearrangement is also divisible by the given number i.e. ’number’.Let us see various input output scenarios for this −Input − int number = 100035Output − Rearrangement of a number which is also divisible by it is: 300105Explanation − we are given an integer number as ‘number’ i.e. 100035. Now, the task is to rearrange these given digits in such a manner that the formed number will be divisible by 100035. So, after rearranging the digits we got ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
855 Views
We are given with a string ‘str’ of any given length. The task is to rearrange the characters in such a manner that the output will be a palindrome string without adding or removing a character from the given input string. Palindrome string is the one in which the characters are arranged in such a manner that they pronounce the same from start and last.Let us see various input output scenarios for this −Input − string str = "itnin"Output − Rearrangement of characters to form palindrome if possible is: nitinExplanation − We are given a string type variable let’s say, str. Now we ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
1K+ Views
We are given an integer type array containing both positive and negative numbers, let's say, arr[] of any given size. The task is to rearrange an array in such a manner that when the lowest element in an array is odd then elements of an array will be rearranged in odd first and even second manner. When the lowest element in an array is even then elements of an array will be rearranged in even first and odd second manner and if the number of even/odd elements is more than the number of odd/even elements then it will place the ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
71 Views
We are given integer variables, let's say, N and K. The task is to firstly calculate the permutation of N and then rearrange the permutation in such a manner that it will be K distance from every element.Let us see various input output scenarios for this −Input − int n = 20, int k = 2Output − Rearrangement of first N numbers to make them at K distance is: 3 4 1 2 7 8 5 6 11 12 9 10 15 16 13 14 19 20 17 18.Explanation − we are given integer variables ‘N’ i.e. 20 and ‘K’ i.e. 2. Now ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
270 Views
We are given an integer type array containing both positive and negative numbers, let's say, arr[] of any given size. The task is to rearrange an array in such a manner that all the elements of an array are sorted using the inbuilt sort function of C++ STL as well as using recursive technique of coding and printing the result.Let us see various input output scenarios for this −Input − int arr[] = {4, 2, -1, -1, 6, -3, 0}Output − Rearrangement of positive and negative numbers with constant extra space is: -3 -1 -1 0 6 2 4.Explanation − we are given ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
986 Views
We are given an integer type array containing both positive and negative numbers, let's say, arr[] of any given size. The task is to rearrange an array in such a manner that all the elements of an array are sorted using the inbuilt sort function of C++ STL as well as using recursive technique of coding and printing the result.Let us see various input output scenarios for this −Input − int arr[] = {4, 2, -1, -1, 6, -3, 0}Output − Rearrangement of positive and negative numbers using inbuilt sort function is: -3 -1 -1 0 2 4 6.Explanation − we are given ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
285 Views
We are given an integer type array containing both positive and negative numbers, let's say, arr[] of any given size. The task is to rearrange an array in such a manner that all positive and negative numbers should be at alternate positions and if there are extra positive or negative elements then they will be placed in the end of an array.Let us see various input output scenarios for this −Input − int arr[] = {4, 2, -1, -1, 6, -3}Output − Rearrangement of positive and negative numbers in O(n) time and O(1) extra space is: 2 - 1 6 -1 4 ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
211 Views
We are given an integer type array containing both positive and negative numbers, let's say, arr[] of any given size. The task is to rearrange an array in such a manner that all the elements at an even position or index should be greater than the elements at an odd position or index and print the result.Let us see various input output scenarios for this −Input − int arr[] = {2, 1, 4, 3, 6, 5, 8, 7}Output − Array before Arrangement: 2 1 4 3 6 5 8 7 Rearrangement of an array such that even positioned are greater than odd ... Read More