1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
azamat
3 years ago
12

Write the following function without using the C++ string class or any functions in the standard library, including strlen(). Yo

u may use pointers, pointer arithmetic or array notation. Write the function lastNotIn(). The function has two parameters (str1, str2), both pointers to the first character in a C-style string. You should be able to use literals for each argument. The function searches through str1, trying to find a match for the last character NOT found in str2. Return the index of the last character in str1 that does NOT appear inside str2. Note that if all of the characters in str1 appear in str2, then return -1. Call the function like this: cout << lastNotIn("eieioh", "aeiou"); // prints 5 (the index of h) cout << lastNotIn("aaaiii", "aeiou"); // prints -1 (all inside s2)
Computers and Technology
1 answer:
Law Incorporation [45]3 years ago
5 0

Answer:

Following are the program to this question:

#include <iostream> //defining header file

using namespace std;

int lastNotIn(string str1, string str2) //defining method lastNotIn

{    

int s1_len=0, i, loc=0, j=0; //defining integer variable

while(str1[s1_len] != '\0') //defining loop that checks str 1 length  

{

s1_len++; // increment length by 1  

}

for(i=s1_len-1;i>=0; i--) //reverse loop for str2

{

   while (str2[j] != '\0') //finding last index value

   {

   if (str1[i] == str2[j]) //comparing all character value

   {  

   loc=1; //assign value 1 in loc variable  

   break; //using break key  

   }

   else //else block

   {

   loc=0; //assign value 0 to loc variable

   }

   j++; //increment loop variable value by 1

   }

   if (loc == 0) //check condition value it is not found then

   {

   return i; //returns value of i

   }

}

  return -1; //return value -1

}

int main() //defining main method

{

  cout<<lastNotIn("eieioh", "aeiou")<<endl; //call method and print its value

  cout<<lastNotIn("aaaiii", "aeiou")<<endl;  //call method and print its value

  return 0;

}

Output:

5

2

Explanation:

In the above program, a method lastNotIn is defined, that accepts two string value "str1 and str2" in its parameter, inside the method four integer variable "s1_len, i, loc, and j" is declared, in which all the variable assign a value that is equal to 0.

  • In the next line, a while loop is declared, that counts str1 value length, and another for loop is used, that reverse value of str2, inside the loop a conditional statement is used, in if the block it will match str1 and str2 value if value match it will assign 0 in loc variable. otherwise, it will go to else block.
  • In this block it will assign 0 in loc variable and increment the j value by 1, outside the loop another if block is used, that check value of loc is equal to 0, if it is true, it will return i value.
  • In the main method, we call the method two times, the first time, it will give value 5, and the second time, it will give 2.  
You might be interested in
What happens it the offshore team members are not able to participate in the iteration demo due to time zone/infrastructure issu
professor190 [17]

The best option that will suite is that there will be no major issues since the offshore leads and the onsite members participated in the demo with the Product Owner/Stakeholders they can cascade the feedback to the offshore members

Explanation:

Iteration demo is the review which is done to gather the immediate feedback from the stakeholders on a regular basis from the regular cadence. This demo will be one mainly to review the progress of the team and the and to cascade and show their working process

They show their working process to the owners and they and the other stakeholders and they get their review from them and so there will be no issues if the members are not able to participate

5 0
3 years ago
What is the relation between Information and Data?
Rudiy27

Answer:

In a sentence: data is raw numbers, while information is organized data.

Explanation:

Data is a series of numbers or facts.  A data set is a collection of data that are related (for examples all the students result in your last math exam).  But it's not organized by itself... and rarely mean anything when looked at it in a raw manner.

To make sense of a data collection, you have to analyze it, calculate the mean or median of the data set for example... this is a treatment that has to be done to a data set to give it significance.. after such analysis, the result you have (mean, median, etc..) is a piece of information devired from the data.

3 0
3 years ago
What type of camera is a cell phone camera
Sergeeva-Olga [200]

Answer:

A camera phone is a mobile phone which is able to capture photographs and often record video using one or more built-in digital cameras. It can also send the resulting image over the telephone function. The first commercial camera phone was the Kyocera Visual Phone VP-210, released in Japan in May 1999.

Explanation:

Hope this kinda helps you :)

3 0
3 years ago
Read 2 more answers
Which of these benefits can be achieved whensoftware is restructured?
Ivenika [448]

Answer:

iv. all of the given options

Explanation:

This is the correct answer because this is what happens when software is restructured.

<em>PLEASE</em><em> </em><em>DO MARK</em><em> </em><em>ME AS</em><em> </em><em>BRAINLIEST</em><em> </em><em>IF</em><em> </em><em>MY ANSWER</em><em> </em><em>IS HELPFUL</em><em> </em><em>;</em><em>)</em><em> </em>

4 0
3 years ago
How to call a variable as a tag in react native.
Pepsi [2]

Explanation:

There is no need of adding template strings inside a <Text> component for adding strings in react-native. You can just use simple text and for variables, you can wrap it with curly braces

6 0
2 years ago
Other questions:
  • What does PHP stand for?
    9·2 answers
  • The date June 10, 1960, is special because when it is written in the following format, the month times the day equals the year:
    5·1 answer
  • Plot element is typically the turning point in the most intense moment of a story
    8·1 answer
  • How does the Rights Management Services feature help to protect information
    11·1 answer
  • In the design phase of the systems development life cycle (SDLC), the _____ design is an overview of the system and does not inc
    10·1 answer
  • Which graph is the solution to the system 2x – 3 and y &lt; 2x + 4?
    5·2 answers
  • Hai<br> ill give 100 point if some won answers dis
    14·2 answers
  • What is professional education? <br><br><br><br><br>Please help me to do this.​
    7·2 answers
  • How will technology help people with disabilities become more transportation independent?.
    5·1 answer
  • What is bigger that terbites
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!