Write a program that takes two strings str1 and str2 from the user and prints the characters that appear in str1 and do not appear in str2 in a single line. It also prints all common characters between str1 and st2 and the character location in str1 and str2 one per line. Each input string is taken from a separate line. IMPORTANT NOTES Please follow the following guidelines when you print the output: • str1 is the first entered string and str2 is the second entered string. • The order of the characters in the output must be in the same order of their appearance in str1 and str2. • Characters in str1 and not in str2 should be printed on one line separated be a single space. If no character satisfies this rule, then the code must output none (all small letters). Each one of the common characters should be printed on a separate line. • When a common character appears at multiple indices in str2, the lowest index is printed. For example, in sample test case 1, the common character 'r' appears at index 1 and index 4 of string Program and the output shows only the lowest index (i.e. 1). • When a common character appears at multiple indices in str1, a separate line must be printed for each appearance. For example, in sample test case 1, the common character 'g' appears at index 2 and index 10 of string Engineering and the output shows 'g' twice according to its order in the string. • The application is not case-sensitive which means that the capital letter and the small letter of the character are treated the same.(i.e. 'C' = 'c').

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter7: User-defined Simple Data Types, Namespaces, And The String Type
Section: Chapter Questions
Problem 3PE
icon
Related questions
Question

c++, pleaaaaaase solve the equation 

1/1
Sample Testcase 0
Input:
Space
Rocket
Output:
spa
c: 32
e: 44
Sample Testcase 1:
Input:
Engineering
Program
Output:
enine ein
g: 23
r: 71
g: 103
Sample Testcase 2:
Input:
Hi
Hi
Output:
none
h: 00
i: 11
Sample Testcase 3:
Input:
welcome
Spain
Output:
welcome
1 #include <iostream>
2
#include <string>
3 using namespace std;
4 int main() {
5
6789
*/
10 }
/* your code starts here
/* your code ends here */
return 0;
||
Transcribed Image Text:1/1 Sample Testcase 0 Input: Space Rocket Output: spa c: 32 e: 44 Sample Testcase 1: Input: Engineering Program Output: enine ein g: 23 r: 71 g: 103 Sample Testcase 2: Input: Hi Hi Output: none h: 00 i: 11 Sample Testcase 3: Input: welcome Spain Output: welcome 1 #include <iostream> 2 #include <string> 3 using namespace std; 4 int main() { 5 6789 */ 10 } /* your code starts here /* your code ends here */ return 0; ||
1/1
Write a program that takes two strings str1 and str2
from the user and prints the characters that appear
in str1 and do not appear in str2 in a single line. It also
prints all common characters between str1 and st2
and the character location in str1 and str2 one per
line. Each input string is taken from a separate line.
IMPORTANT NOTES
Please follow the following guidelines when you print the
output:
1/0
• str1 is the first entered string and str2 is the
second entered string.
• The order of the characters in the output must be
in the same order of their appearance in str1 and
str2.
• Characters in str1 and not in str2 should be printed
on one line separated be a single space. If no
character satisfies this rule, then the code must
output none (all small letters).
• Each one of the common characters should be
printed on a separate line.
• When a common character appears at multiple
indices in str2, the lowest index is printed. For
example, in sample test case 1, the common
character 'r' appears at index 1 and index 4 of
string Program and the output shows only the
lowest index (i.e. 1).
• When a common character appears at multiple
indices in str1, a separate line must be printed for
each appearance. For example, in sample test case
1, the common character 'g' appears at index 2 and
index 10 of string Engineering and the output
shows 'g' twice according to its order in the string.
• The application is not case-sensitive which means
that the capital letter and the small letter of the
character are treated the same.(i.e. 'C' = 'c').
Program Input:
Two lines each containing any string.
Program Output:
The first line shows characters in str1 and not in
str2, all on the same line separated by white
space. N separate lines where each line has a
lette at is common between str1 but not in
str2 and its location (order starting from location
0) in str1 and str2.
=
Transcribed Image Text:1/1 Write a program that takes two strings str1 and str2 from the user and prints the characters that appear in str1 and do not appear in str2 in a single line. It also prints all common characters between str1 and st2 and the character location in str1 and str2 one per line. Each input string is taken from a separate line. IMPORTANT NOTES Please follow the following guidelines when you print the output: 1/0 • str1 is the first entered string and str2 is the second entered string. • The order of the characters in the output must be in the same order of their appearance in str1 and str2. • Characters in str1 and not in str2 should be printed on one line separated be a single space. If no character satisfies this rule, then the code must output none (all small letters). • Each one of the common characters should be printed on a separate line. • When a common character appears at multiple indices in str2, the lowest index is printed. For example, in sample test case 1, the common character 'r' appears at index 1 and index 4 of string Program and the output shows only the lowest index (i.e. 1). • When a common character appears at multiple indices in str1, a separate line must be printed for each appearance. For example, in sample test case 1, the common character 'g' appears at index 2 and index 10 of string Engineering and the output shows 'g' twice according to its order in the string. • The application is not case-sensitive which means that the capital letter and the small letter of the character are treated the same.(i.e. 'C' = 'c'). Program Input: Two lines each containing any string. Program Output: The first line shows characters in str1 and not in str2, all on the same line separated by white space. N separate lines where each line has a lette at is common between str1 but not in str2 and its location (order starting from location 0) in str1 and str2. =
Expert Solution
steps

Step by step

Solved in 2 steps with 4 images

Blurred answer
Knowledge Booster
Time complexity
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr