#include<iostream>
#include<algorithm>
#include<string>
#include<list>
struct node {
std::string m_word;
unsigned m_freq;
node (std::string word): m_word (word), m_freq (1) {}
};
struct list {
friend std::ostream& operator<<(std::ostream& os, list& lst);
std::list<node> m_list;
list (std::string text)
{
// delimiters: space, comma, full-stop, tab, newline & null characters
std::string delimits = " ,.\t\n\0";
unsigned start = 0, end = 0;
while (end<text.size())
{
// move start position to the start of the next word
start = end;
while (start<text.size() && delimits.find (text[start]) != std::string::npos)
++start;
// move end position to the first delimiter after the start position
end = start + 1;
while (end<text.size() && delimits.find (text[end]) m_list.end())
m_list.push_back (node(word));
else
++(*n).m_freq;
}
};
std::ostream& operator<<(std::ostream& os, list& lst)
{
for (std::list<node>::iterator i=lst.m_list.begin(); i!=lst.m_list.end(); ++i)
{
// dereference the node
node& n = *i;
os << n.m_word << " (" << n.m_freq << ")\n";
}
return (os);
}
int main()
{
std::string text = "We shall fight in France, we shall fight on the"
" seas and oceans, we shall fight with growing confidence and"
" growing strength in the air, we shall defend our island,"
" whatever the cost may be.";
list table (text);
std::cout << "Text: \n"" << text << ""\n" << std::endl;
std::cout << "Unique words (frequency)\n" << std::endl;
std::cout << table << std::endl;
}
Output:
Text:
"We shall fight in France, we shall fight on the seas and oceans, we shall fight
with growing confidence and growing strength in the air, we shall defend our
island, whatever the cost may be."
Unique words (frequency)
we (4)
shall (4)
fight (3)
in (2)
france (1)
on (1)
the (3)
seas (1)
and (2)
oceans (1)
with (1)
growing (2)
confidence (1)
strength (1)
air (1)
defend (1)
our (1)
island (1)
whatever (1)
cost (1)
may (1)
be (1)
Based on the data given, what is the sustainability of your program?
No. Serial numbers aer NOT UNIQUE. They are intended to be unique to a given make and model- but a gun can be rebarreled to a different caliber.
Chirality centers are carbon atoms that are bonded to four different groups. In the given structure, you can identify chirality centers by looking for carbon atoms with four unique groups attached to them.
A grant was given to the program amounting to 120,000 dollars.
Resource Advisors (RAs)
Resource Advisors (RAs)
Resource Advisors (RAs)
Resource Advisors (RAs)
program to extract a given word from a file
The question is impossible to answer. You cannot determine an algorithm from a given program if the program is not actually given in the question. Please place the program in the discussion section.
file is a set of data and program that has been given a name
Given a good microscope I can identify all parts of an onion cell.