
C++
I have code:
#include <bitset>
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
const std::string MORSE_CODE[] = {".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--..", "-----", ".----", "..---", "...--", "....-", ".....", "-....", "--...", "---..", "----."};
const char MORSE_DELIM = ' ';
string decodeMorse(const string& morse) {
string message;
string word;
bitset<8> bits;
int bitIndex = 0;
for (char c : morse) {
if (c == MORSE_DELIM) {
int letterIndex = -1;
for (int i = 0; i < 26; ++i) {
if (word == MORSE_CODE[i]) {
letterIndex = i;
break;
}
}
if (letterIndex != -1) {
bits.set(bitIndex, letterIndex & 1);
++bitIndex;
bits.set(bitIndex, (letterIndex >> 1) & 1);
++bitIndex;
bits.set(bitIndex, (letterIndex >> 2) & 1);
++bitIndex;
bits.set(bitIndex, (letterIndex >> 3) & 1);
++bitIndex;
}
else if (word.empty()) {
bits.set(bitIndex, 0);
++bitIndex;
}
word.clear();
}
else {
word.push_back(c);
}
}
if (!word.empty()) {
int letterIndex = -1;
for (int i = 0; i < 26; ++i) {
if (word == MORSE_CODE[i]) {
letterIndex = i;
break;
}
}
if (letterIndex != -1) {
bits.set(bitIndex, letterIndex & 1);
++bitIndex;
bits.set(bitIndex, (letterIndex >> 1) & 1);
++bitIndex;
bits.set(bitIndex, (letterIndex >> 2) & 1);
++bitIndex;
bits.set(bitIndex, (letterIndex >> 3) & 1);
++bitIndex;
}
else {
bits.set(bitIndex, 0);
++bitIndex;
}
}
for (int i = 0; i < bitIndex; i += 8) {
char ch = static_cast<char>(bits.to_ulong());
message.push_back(ch);
bits.reset();
}
return message;
}
Please help me write int main(){} to read the file below. Write a Tuple Search
Bin.bin when open with Visual Studio
RI…‰&!:¢E(šQ…¥9‰Š‰Ù…E%ŠD‰Ž¡˜¢J*”ª9I*5F#T¦4ª#¦(˜¨M˜TRX¤H˜ê)„”’b9baQbbE‰Š‰™:Š¢6bb$HhÒ¨"aN¡R˜II&#†(b"cEM¢*‰Šˆêˆ˜å&&dê*ˆêˆš%ˆhå&(HÒ¨˜TRX¤H˜Ù…Fˆé…I*ˆÙ…E‘†ŽF9¢‘‰&5)&ˆ¨é*!£TcJ¢9%…I¢hTÔ¢¢¢…F*4TÒ¨EEF:Ò¨Žh‘#•EXj…T¨äa£‰&&†SZ…T¨™“”ª(š#¨JF†R†5$J¢‘(f*9h劢‰¡R¡RXªNDâI‰¢¨‘M˜Tš&ˆXކ9ŠŠ¡EF”èa¢‰‘iN¢¨HNT‘H¨ê‰¢hEF”äa£J¢N¢‘¨¨…’’I¡”Ô’bbˆh™“’˜H˜Ö&$h¤‘(ac¡ŽUbª¡iN¢¨$¤Xªª(Xª:†b¨TTš5$J¢‘(f*:aRc“¨ª&J‰™4ª#f)%‰¢4ª!EJ’4TÚ…J„TbfNI¡*…JEŠ£RI…‰&!9bh‘†!£EN¡)NF¢¡&$fRDª!I†b£‘6¢bF"ŠŽ‘Š*H˜¨¡E¥:Š¢9†b%„†ŽNTTj9J¢5$¨¨‘˜ª)*!£¡Š„¡)5JcHf*†&…E†S”ª(š#ª"cª)*‰häD†!£ª$˜©$˜hæ‰%:†b¨TTš&däMJ¨ª#j!bF9baQbbE¡…Ž¡R˜II&#ENX˜†Š„Ò¨ŽR$J¢&9hÚ(hå…J„X˜‘¢’DŽQRa“¡HHT˜TšI™:Ò¨Ž$˜šNUaªR£ª$R‰¡åEJ†J£š(a˜T𿉅I‰Ra”ZS”ª"b:Š¢9I*:©&Š’:Ò¨Ž¢EˆáŠ’‰…F†–&%HfiM*ˆéŠ&*¤™’¢fNJ&6ˆ¦!ŠˆêJ„…&dê*ˆØTI‰¡”å&:…Ja%$˜Ž˜T˜ä剅E‰‰ÑS¡¢J)†S†!FS’‰†bbJa&dꉢhEF6!¤NQRa’9R„¨èb¡&)†D¡QŽh‘¨T˜‘&E¥9J¢†b¨å‰…J’†ˆh䉅F$¤J‰&!˜ªTšN˜T˜Ø’¢I™:Š¢9¢94‰Ò¨‘9I*4’¡’9J¨Ú"¤‰¡RX¡…*ˆê)„”’b:aRcJ¢5ŠJ$a˜ŽF6aQ„˜Tš:†R¡!JR˜Ò¨Ž†
bh¡b¨M˜TQIhäa£š)’cQQ¢’hŠR˜Ò¨ŽIaRhš5(¨¨¡QЉ™9J¢4¡HZSaS¨f*…EI¢£I)*„ê)„”’b8ab†"&(aaiN¡SJ¢4‰Ô…ˆ˜¨ê‰4Tå&5JDäa”剅F¢h…*5F4ª"‰RQ‰™:¢E(šQލ‰Šˆš)Ž¢X†bŠb†bI¢he6aQ†bI‰5F:…Ja%$˜6ˆHf¨e*âbaRb£‘†9ˆf*H˜èb˜T˜RD¡Qކ96aQIb‘"cf&$¨ª&dÚ…Dª4ª*#‰¢†£”‰ˆÙ‰ŠFb‰&¢’b†4ª#’XTš&…NU%SRŠŠŠZS”ª(f*9*aQ‰)£b(š9&¨I…F9hÚŠE¡häš&(cEM*ˆÔTTbfN¨‘J&„Tcš"˜MJ¡*ˆÔ¡£•EXZ…T¨ÑS”T˜dècJ¢9bbŠ’DŽ¢„T˜™“¨ª#f)…JF!£J¢6aQIbFN¨¡b¨‰Ra¢&:…Ja%$˜Ž†9TU…¨jŽF8¨I‰¢ŠŠ¢:¢E(šQ!˜ªTš(ŠŽUSe"IŠŽh‘"bfOª$R‰¡å$¨Ò¨ŽbŠ%Š!„Õ)ޤ’b…JJލTaRb¡iN†‰¢‘¢†6$¨’£†‘˜‰a(TbI£¨–$f#‘˜NII&&d剈¨™“j$˜‘˜dÕ‰“–&"¢Hhꈘå(J£J¢9bb*(h†‰&Hh’hÕ)Ž˜˜ˆhTS¡Ž•RU¢f@

Trending nowThis is a popular solution!
Step by stepSolved in 3 steps

- c++arrow_forward//main.cpp #include "Person.h"#include "Seller.h"#include "Powerseller.h"#include <iostream>#include <list>#include <fstream>#include <string> using namespace std; void printMenu();void printSellers(list<Seller*> sellers);void checkSeller(list<Seller*> sellers);void addSeller(list<Seller*> sellers);void deleteSeller(list<Seller*> &sellers); int main() { list<Seller*> sellers; ifstream infile; infile.open("sellers.dat"); if (!infile) { cerr << "File could not be opened." << endl; exit(1); } char type; while (!infile.eof()) { infile >> type; if (type == 'S') { Seller* newseller = new Seller; newseller -> read(infile); sellers.push_back(newseller); } if (type == 'P') { Powerseller* newpowerseller = new Powerseller; newpowerseller -> read(infile); sellers.push_back(newpowerseller); } } infile.close();…arrow_forward#include#include#includeusing namespace std;// outputHtmlTitle// parameters// This function...void outputHtmlTitle(ofstream & fout, string title){fout << "" << endl;fout << "" << endl;fout << "" << endl;fout << "" << endl;fout << title << endl;fout << "" << endl;}void outputHtmlFooter(ofstream & fout){fout << "" << endl;fout << "" << endl;}void outputHtmlList(ostream & fout, string first, string second, string third){fout << "" << endl;fout << "\t" << first << "" << endl;fout << "\t" << second << "" << endl;fout << "\t" << third << "" << endl;fout << "\t" << endl;}void main(int argc, char * *argv){ofstream htmlFile("myIntro.html");string title;cout << "Please enter the title: ";getline(cin, title);outputHtmlTitle(htmlFile, title);string name;string course1, course2, course3;cout…arrow_forward
- C++ Programmingarrow_forwardC++ this is my code so far need help with part 9 #include <iostream> #include <string> using namespace std; int GetNumOfNonWSCharacters(const string text); int GetNumOfWords(const string text); int FindText(string text, string sample_text); string ReplaceExclamation(string text); string ShortenSpace(string text); char PrintMenu(){ char option; cout << "\nMENU"<<endl; cout << "c - Number of non-whitespace characters"<<endl; cout << "w - Number of words"<<endl; cout << "f - Find text"<<endl; cout << "r - Replace all !'s"<<endl; cout << "s - Shorten spaces"<<endl; cout << "q - Quit"<<endl; cout<<endl; cout << "Choose an option:"<<endl; cin >> option; return option; } void ExecuteMenu(string sample_text,char option){ if(option == 'c'){ int nonWSCharacters = GetNumOfNonWSCharacters(sample_text); cout << "Number of non-whitespace characters:…arrow_forwardpalindromes Write a function palindromes that accepts a sentence as an argument. The function then returns a list of all words in the sentence that are palindromes, that is they are the same forwards and backwards. Guidelines: • punctuation characters .,;!? should be ignored • the palindrome check should not depend on case Sample usage: >>> palindromes ("Hey Anna, would you prefer to ride in a kayak or a racecar?") ['Anna', 'a', 'kayak', 'a', 'racecar'] >>> palindromes ("Able was I ere I saw Elba.") ['I', 'ere', 'I'] >>> palindromes ("Otto, go see Tacocat at the Civic Center, their guitar solos are Wow!") ['Otto', 'Tacocat', 'Civic', 'solos', 'wow'] >>> palindromes ("Otto, go see Tacocat at the Civic Center, their guitar solos are wow!")==['Otto', 'Tacocat', 'Civic', 'solos', 'wow'] Truearrow_forward
- C++ PLEASE!! // FILE: simplestring.h// CLASS PROVIDED: string (a sequence of characters)//// CONSTRUCTOR for the string class:// string(const char str[ ] = "") -- default argument is the empty string.// Precondition: str is an ordinary null-terminated string.// Postcondition: The string contains the sequence of chars from str.//// CONSTANT MEMBER FUNCTIONS for the string class:// size_t length( ) const// Postcondition: The return value is the number of characters in the// string.//// char operator [ ](size_t position) const// Precondition: position < length( ).// Postcondition: The value returned is the character at the specified// position of the string. A string's positions start from 0 at the start// of the sequence and go up to length( )-1 at the right end.//// MODIFICATION MEMBER FUNCTIONS for the string class:// void operator +=(const string& addend)// Postcondition: addend has been catenated to the end of the string.//// void operator +=(const char addend[ ])//…arrow_forwardMorse Code (python ) Morse code maps each letter of the alphabet to a series of dashes and dots (a = .-). The list of the Morse code for all English letters (from a to z) is provided below: [".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","- -","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.-- ","--.."] Your goal here is to implement a function that takes a list of strings as its only parameter (called “words”). Each of the words can be transformed to Morse code by concatenation of a number of the above strings (without spaces). For example, the transformation of “ab” will be “.--...” (“.-” + “-...”). The word “ems” will also have the same transformation “.--...” (“.” + “--” + “...”). In this function, the goal is to return the number of the unique transformations in “words” list. Here is an example (none of this is needed to be printed, the function will only return one integer): Words = [“ab”, “a”, “ems”]Returned value: 2Explanation:…arrow_forward#include <iostream>#include <sstream>#include <string>using namespace std; int main() { string userItem; ostringstream itemsOSS; cout << "Enter items (type Exit to quit):" << endl; cin >> userItem; while (userItem != "Exit") { cin >> userItem; } cout << itemsOSS.str() << endl; return 0;}arrow_forward
- please use DEQUE #include <iostream>#include <string>#include <deque> using namespace std; const int AIRPORT_COUNT = 12;string airports[AIRPORT_COUNT] = {"DAL","ABQ","DEN","MSY","HOU","SAT","CRP","MID","OKC","OMA","MDW","TUL"}; int main(){// define stack (or queue ) herestring origin;string dest;string citypair;cout << "Loading the CONTAINER ..." << endl;// LOAD THE STACK ( or queue) HERE// Create all the possible Airport combinations that could exist from the list provided.// i.e DALABQ, DALDEN, ...., ABQDAL, ABQDEN ...// DO NOT Load SameSame - DALDAL, ABQABQ, etc .. cout << "Getting data from the CONTAINER ..." << endl;// Retrieve data from the STACK/QUEUE here } Using the attached shell program (AirportCombos.cpp), create a list of strings to process and place on a STL DEQUE container. Using the provided 3 char airport codes, create a 6 character string that is the origin & destination city pair. Create all the possible…arrow_forward// SumAndProduct.cpp - This program computes sums and products // Input: Interactive// Output: Computed sum and product #include <iostream>#include <string>void sums(int);void products(int);using namespace std; int main() { int number; cout << "Enter a positive integer or 0 to quit: "; cin >> number; while(number != 0) { // Call sums function here // Call products function here cout << "Enter a positive integer or 0 to quit: "; cin >> number; } return 0;} // End of main function// Write sums function here// Write products function herearrow_forwardC++arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





