Computer Science, asked by priyanka4123, 11 months ago

1 Write a program that will replace multiple consecutive occurrences of a character with single occurrence, and print the result in the reverse order.
For example, if the input string is aaaaEEGCCCCCxEEf , the output should be fExCcGEa
The input string of characters should be read from STDIN and the result should be written to STDOUT
Other than the required output, no other characters / string or message should be written to STDOUT.
You can assume that the input string length will not exceed 30 characters
Sample Testcases:
Testcase 1 Input
Testcase 1 Output
aaaaEE GCCCCCCCXEE
fEXCOGES​

Answers

Answered by sailorking
1

Answer:

#include<stdio.h>

int main ()

{

             char a [15];

            cout <<" Enter a string "<< endl ;

            cin >>  a ;

            cout << a [ 0 ];

             for (int i = 1; i < 15; i++)

             {

                     if ( a [i] != a [i-1] )

                     {

                                cout << a [i] ;

                      }  

              }

return 0;

}

Explanation:

Here the program accepts a string, using the "stdio" header and then checks every character of the word that whether it is same as the previous character, if it is not same then it is printed else it is skipped.

Answered by jyothsna15152
1

Explanation:

1 Write a program that will replace multiple consecutive occurrences of a character with single occurrence, and print the result in the reverse order.

For example, if the input string is aaaaEEGCCCCCxEEf , the output should be fExCcGEa

The input string of characters should be read from STDIN and the result should be written to STDOUT

Other than the required output, no other characters / string or message should be written to STDOUT.

You can assume that the input string length will not exceed 30 characters

Sample Testcases:

Testcase 1 Input

Testcase 1 Output

aaaaEE GCCCCCCCXEE

fEXCOGES

Similar questions