C++ Programming:
Write a function that takes in a C++-style string s (from #include ), as well as an integer n, and then returns true if any substring of length n in s repeats itself, and false otherwise. For example, if s is "toe-to-toe" and n is 3, then the function would return true since "toe" occurs twice within s. However, if n were 4, the function would return false. As a second example, if s is "singing" and n is 2, then the function would return true since, e.g., "in" appears more than once (as does "ng"). In this problem you may use any of the C++ string member functions.
code:
#include <iostream>
//for string operstions
#include <string>
//includiing the namespace standard
using namespace std;
//function for calculating the substring
int ssc(const string& givenst, const string& stsub)
{
if (stsub.length() == 0) return 0;
int cnt = 0;
int n =2;
for (size_t offset = givenst.find(stsub); offset !=
string::npos;
offset = givenst.find(stsub, offset +
stsub.length()))
{
cnt++;
}
if(cnt==n)
{
return 1;
}
else
{
return 0;
}
}
int main()
{
int l,m;
l=ssc("TOE-TO-TOE", "TOE");
m= ssc("SINGING", "ING");
if(l==1)
{
cout<< "TRUE \n";
}
else
{
cout<<"FALSE \n";
}
if(m==1)
{
cout<< "TRUE \n";
}
else
{
cout<<"FALSE \n";
}
return 0;
}
C++ Programming: Write a function that takes in a C++-style string s (from #include ), as...
C++ programming language Write a program that contains following function: A function that receives a string of character, the function return true if the string contains letter c or C, otherwise, return false.
Write a function is_mirror(s) that takes as input a string s and returns True if s is a mirrored string (i.e., a string that could have been produced by your mirror function) and False otherwise. Examples: >>> is_mirror('baconnocab') result: True >>> is_mirror('baconnoca') result: False Warning Your function should return a boolean value – either True or False, without any quotes around them. If you see quotes around the result when you make the calls above from the console, you must...
Q1)(20p)Write a static member function called removeLongestRepeatingSegment that takes a String argument. The method will return a new String by removing the logest segment that contains consequtively repeating characters. public static void main(String []args){ String s=”1111222223333311111111444455552222”; String res= removeLongestRepeatingSegment(s); will return “11112222233333444455552222” } public static String removeLongestRepeatingSegment(String s){ --------------- Q2)15p)Given a list of objects stored (in ascending order) in a sorted linked list, implement member method which performs search as efficiently as possible for an object based on a key....
Write a function check palindrome, which takes a string x as argument and which returns True if x is a palindrome, and False otherwise. A palindrome is a word that reads the same backwards as forwards (like for example “racecar”). Your function should be recursive (i.e. call itself) and proceed as follows. 1. If x is a string of length 0 or 1 return True. 2. If the rst and the last letter of x are di erent, return False....
Using the programming language Java or C++, Write a function that takes an integer as input. Return true if this integer is a palindrome integer; false otherwise;
Haskell Functional Programming Language: Write a function nestedParens that takes a string argument and returns true if it is a nesting of zero or more pairs of parentheses, e.g. "((()))" should return True ; "()()" or "(()))" should return False . Use recursion for this problem. nestedParens :: String -> Bool
Write a function “ssnChecker” that takes a string “s” and validates if the string is in a valid social security number format (999-99-9999). The function must return a Boolean value (True or False).
C++ PROGRAMMING Implement a bool function whose header is given below. Inside the function, declare, ask, and get a character from the user. The function will return true if the character the user enters is NOT in either of the words, otherwise it will return false. Keep in mind that uppercase and lowercase letters are not the same. You will need to change both words and the character input by the user to the same case (upper or lower) -...
using basic c++ and use no functions from c string library b) Write a fragment of code (with declarations) that reads a pair of words from the keyboard and determines how many letters in corresponding positions of each word are the same. The words consist only of the letters of the English alphabet (uppercase and lowercase). For example, if the words are coat and CATTLE, the following output should be generated: 012245 0122 matching letter in position 0 t is...
Please use python 3 programming language Write a function that gets a string representing a file name and a list. The function writes the content of the list to the file. Each item in the list is written on one line. Name the function WriteList. If all goes well the function returns true, otherwise it returns false. Write another function, RandomRange that takes an integer then it returns a list of length n, where n is an integer passed as...