rom the user and prints the characters that appear n str1 and do not appear in str2 in a single line. It als prints all common characters between str1 and st2 and the character location in str1 and str2 one per ne. Each input string is taken from a separate line.
rom the user and prints the characters that appear n str1 and do not appear in str2 in a single line. It als prints all common characters between str1 and st2 and the character location in str1 and str2 one per ne. Each input string is taken from a separate line.
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
C++ please solve the equationnnnnn
![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
letter that is common between str1 but not in
str2 and its location (order starting from location
0) in str1 and str2.
||](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F129dcb19-44ff-4985-aef9-1882dca9f41b%2F9a6662b5-2547-4fdc-9148-360e5fc879fe%2Fyucmqzn_processed.jpeg&w=3840&q=75)
Transcribed Image Text: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
letter that is common between str1 but not in
str2 and its location (order starting from location
0) in str1 and str2.
||
![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
*/
6
7
8
9
10 }
/* your code starts here
/* your code ends here */
return 0;
||](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F129dcb19-44ff-4985-aef9-1882dca9f41b%2F9a6662b5-2547-4fdc-9148-360e5fc879fe%2Fokxp4e7_processed.jpeg&w=3840&q=75)
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
*/
6
7
8
9
10 }
/* your code starts here
/* your code ends here */
return 0;
||
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
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.Recommended textbooks for you
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education