In C Computer science Why 2 Search on Youtube about search a

In C++
Computer science
Why? 2. Search on Youtube about \'search algorithm.animation\'? Provide the link of three of 2. Search on Youtube about \'searchalgorithmanimatio them. 4) What is a searching algorithm? 5) What are the programming languages that can implement \'searching algorithms Then write a small essay more than 200 words answering the following questio 6) What is your favorite searching algorithm among the ones in your YouTube search Why? S-303 Project4 ot Program 1. 1. Create a SortedList called Texas.flowers with 15 names or less, each name in one line. The names may contain \"\" to connect different words. Use the computer program to perform the following tasks in a sequence: G//n1../~ 1) Create a new file called Texasflowers.beautiful. 2) Calculate the number of unique names of the \'Texas.flowers\', and print the number and the names out in Texasflowers.beautuiful 3) names out in \'Texasflowers.beautiful\' Delete a name that is specified in the computer program, and print the rest of the 4 4) In the console, ask the user which is his or her favorite flower. The user may input In the console, ask the user which is his or her favorite flower. The user may input \"coneflowers\", or other names. 5) Insert the name as the favorite flower, and print the current list of names in Texasflowers.beautiful\' 6) Use \'isPresent\' to search whether the favorate flower that the user entered is in the list, and print the result in the console. TR

Solution

Code:

#include <iostream>
#include <fstream>
#include <vector>
#include <string>
using namespace std;

int main()
{
   char data[100];
ifstream input;
vector <string> listofFlowers;
input.open(\"Texas.flowers\");
cout << \"Reading data from a file :-\" << endl << endl;
while (!input.eof()) {
input.getline(data, 100);
listofFlowers.push_back(data);
}
input.close();
vector<string> distinctFlowers;
vector<int> nInt;

for(int i=0;i<listofFlowers.size();i++)
   {
       bool duplicate=false;

       for(int j=0;j<distinctFlowers.size();j++)
       {
           if(listofFlowers[i]==distinctFlowers[j])
           {
               nInt[j]+=1;
               duplicate=true;
               break;
           }
       }
       if (duplicate==false)
       {
           distinctFlowers.push_back(listofFlowers[i]);
           nInt.push_back(1);
       }
   }
ofstream output;
output.open(\"Texasflowers.beautiful\");
output << \"Number of unique names flowers:\";
output<< distinctFlowers.size();
output<<endl;

for(int i=0;i<distinctFlowers.size();i++)
        output<<distinctFlowers[i]<<endl;

output<<\"Removing the name buttercup\"<<endl;

listofFlowers.erase(listofFlowers.begin()+2);

for(int i=0;i<listofFlowers.size();i++)
        output<<listofFlowers[i]<<endl;

string str;
cout<<\"What is your favourite flower? \"<<endl;
cin>>str;
int flag=0;
for(int i=0;i<listofFlowers.size();i++){

    if(str==listofFlowers[i])
        {
            cout<<str<<\" Exists in the list!\";
            flag=1;
            break;
        }

}

   if(flag==0)
   {
        listofFlowers.push_back(str);
}

output<<\"Current List of flowers:\"<<endl;

for(int i=0;i<listofFlowers.size();i++)
        output<<listofFlowers[i]<<endl;
    output.close();

   return 0;
}

Input:

bluebonnet
indian_paintbrush
buttercup
indian_blanket
verbana
indian_paintbrush

Output:

Number of unique names flowers:5
bluebonnet
indian_paintbrush
buttercup
indian_blanket
verbana
Removing the name buttercup
bluebonnet
indian_paintbrush
indian_blanket
verbana
indian_paintbrush
Current List of flowers:
bluebonnet
indian_paintbrush
indian_blanket
verbana
indian_paintbrush
Lily

Console:

Reading data from a file :-

What is your favourite flower?

Lily

In C++ Computer science Why? 2. Search on Youtube about \'search algorithm.animation\'? Provide the link of three of 2. Search on Youtube about \'searchalgorith
In C++ Computer science Why? 2. Search on Youtube about \'search algorithm.animation\'? Provide the link of three of 2. Search on Youtube about \'searchalgorith
In C++ Computer science Why? 2. Search on Youtube about \'search algorithm.animation\'? Provide the link of three of 2. Search on Youtube about \'searchalgorith

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site