In this task you are required to find the common characters between strings according to certain rules and print out the result on the screen.
In this task you are required to find the common characters between strings according to certain rules and print out the result on the screen.
In this task you are required to:
Write a program which takes two string inputs Str1 and Str2 in addition to the mode integer value.
If the value of the mode operation is not 0 or 1 then you have to print "Invalid"
According to mode value you have to do the following
mode=0: you have to print out the alphapatical characters that appears in Str1 but not in Str2. This operation is case sensitive which means that the lowercase and the uppercase of the same character are not the same. If the number of characters that meet this condition is 0 then you have to print None.
mode=1: you have to print out the alphapatical characters that appear in Str1 and Str2. This operation is case insensitive which means that you treat the uppercase and the lowercase letters the same. If the number of characters that meet this condition is 0 then you have to print None.
IMPORTANT NOTE
Do not add any cout statements except for the final answers as specified above.
Do not add "Enter a number", "the number of digits is" or any similar prompts.
Also note that it is case-sensitive; so "NONE" is wrong but "None" is correct.
Do not add any unnecessary spaces inside the strings of cout statements " " unless we ask you to.
You may add any libraries needed.
I/O
Program Input:
Two strings and one Integer number
Program Output:
One line that contains the characters that meet the operation specified by the mode without separations (not spaces)
Sample Testcase 0:
Input:
WElcome to C++
ear
0
Output:
WElcomtoC
Sample Testcase 1:
Input:
Welcome to C++
ear
1
Output:
ee
Sample Testcase 2:
Input:
Welcome to C++
ear
2
Output:
Invalid
Sample Testcase 3:
Input:
Welcome to C++
java
1
Output:
None
int main()
{
1
#include <iostream>
2
#include <ctime> // for time function
3
#include <cstdlib> // for rand and srand functions
4
using namespace std;
5
6
int main()
7
{
8
string Str1, Str2;
9
int mode;
10
getline(cin, Str1);
11
getline(cin, Str2);
12
cin>>mode;
13
//Your code Starts Here
14
15
16
return 0;
17
18
}
19
20
Step by step
Solved in 2 steps with 5 images