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
Oxana [17]
3 years ago
5

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 lastOfAny().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 any character inside str2.Return the index of the last character in str1 where this occurs.
Computers and Technology
1 answer:
dolphi86 [110]3 years ago
4 0

Answer:

The function in C++ is as follows

int chkInd(string str1, string str2){    

int lenstr1=0;

while(str1[lenstr1] != '\0'){  lenstr1++;  }

int index = 0; int retIndex=0;

for(int i=lenstr1-1;i>=0; i--){

   while (str2[index] != '\0'){

       if (str1[i] == str2[index]){

           retIndex=1;

           break;         }

       else{   retIndex=0;      }

  index++;    }

  if (retIndex == 0){   return i;   }else{return -1;}}

}

Explanation:

This defines the function

int chkInd(string str1, string str2){    

First, the length of str1 is initialized to 0

int lenstr1=0;

The following loop then calculates the length of str1

while(str1[lenstr1] != '\0'){  lenstr1++;  }

This initializes the current index and the returned index to 0

int index = 0; int retIndex=0;

This iterates through str1

for(int i=lenstr1-1;i>=0; i--){

This loop is repeated while there are characters in str2

   while (str2[index] != '\0'){

If current element of str2 and str1 are the same

       if (str1[i] == str2[index]){

Set the returned index to 1

           retIndex=1;

Then exit the loop

           break;         }

If otherwise, set the returned index to 0

       else{   retIndex=0;      }

Increase index by 1

  index++;    }

This returns the calculated returned index; if no matching is found, it returns -1

  if (retIndex == 0){   return i;   }else{return -1;}}

}

You might be interested in
Traceability of requirements is helpful in the followingexcept
larisa86 [58]

Answer: D)  Identifying GUI's for a particular requirement

Explanation:

 Traceability of requirements is helpful except identifying GUI's for a particular requirements as, traceability in project management describe the relationships between two or more element throughout in the development process and outline the relationship between the customer requirement by traceability matrix. And the requirement of traceability is so important because it creating a downstream flow of software and test cases in software requirement but not helpful in GUI identification.

6 0
3 years ago
What are the different types of topology?​ in details
wlad13 [49]

Answer:

<h2> <u>NETWORK</u> <u>TOPOLOGY</u> .</h2>

This tefers to how nodes are connected to the network.

Types of topology.

  • Physical topology.
  • Logical topology.

In physical topology,nodes are connected physically using wires(cables).

Types of physical topology include:

  • Bus topology
  • Tree topology
  • Hybrid topology
  • Star topology
  • Ring topology.

Hope it helps you,any question so far...comment !!!

3 0
2 years ago
Read 2 more answers
HURRRYYYY PLZZ!!
vivado [14]

Answer: A. How much is this vehicle's resale value?

6 0
3 years ago
Read 2 more answers
Terrence smiles at his customers, helps his coworkers, and stays late when needed. What personal skill does Terrence demonstrate
Salsk061 [2.6K]
Friendliness or it shows that he follows the rules
6 0
3 years ago
Read 2 more answers
Similarities between human and computer​
Zielflug [23.3K]

Answer: Both have a center for knowledge; motherboard and brain. Both have a way of translating messages to an action. Both have a way of creating and sending messages to different parts of the system.

5 0
3 years ago
Other questions:
  • Which icon will automatically adjust the amount of space between letters from very tight to very loose in style? Hyphenation, Te
    6·2 answers
  • Name a computer programme that designers are likely to use to create a leaflet advertising their new product
    15·1 answer
  • What does this say:<br> √ans
    6·2 answers
  • Design an algorithm for a bounded-buffer monitor in which the buffers (portions) are embedded within the monitor itself."
    10·1 answer
  • Which of the following software programs provides for e-mail communication?. A. Access. B. Word Perfect. C. Outlook. D. Excel
    15·2 answers
  • Write a program to calculate the great circle distance between two points on the surface of a sphere. If p1(x1, y1) and p2(x2,y2
    5·1 answer
  • What should be done if a system cannot boot from the hard drive?
    14·1 answer
  • What operating system are you using? On most computers, you can answer this question by right-clicking on the "My Computer" icon
    6·2 answers
  • What is a man-in-the-middle attack​
    14·2 answers
  • your manager asked you to set up a secure network connection at a remote site to move over some back ups. what protocol what do
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!