<prompt> Unda programu ya C ambayo inabana na kupunguza faili kwa kutumia algoriti ya LZ77. Programu inapaswa kukubali hoja za mstari wa amri kwa faili ya ingizo, faili ya pato, na hali ya uendeshaji finyaza au punguza.  <response>: Hapa kuna utekelezaji rahisi wa algorithm ya LZ77 katika C ya kukandamiza na kupunguza faili. Hifadhi msimbo huu kama lz77.cpp.cpppamoja na pamoja na pamoja na pamoja na pamoja na kutumia nafasi ya majina std;kubana utupuconst string input_file, const string output_file ifstream ifsinput_file, ios::binary; ofstream ofsoutput_file, ios::binary; vector buffer; ramani kamusi; char c; string current_string ; wakati ifs.getc current_string c; ikiwa dictionary.findcurrent_string dictionary.end kamusicurrent_string buffer.size; buffer.push_backc; current_string ; ikiwa !current_string.empty int position dictionarycurrent_string.substr0, current_string.length - 1; ofs.writereinterpret_castposition, sizeofnafasi; ofs.andikac, sizeofc; kwa char b: buffer ofs.andikab, sizeofb; ifs.close; ofs.funga;decompress batiliconst string input_file, const string output_file ifstream ifsinput_file, ios::binary; ofstream ofsoutput_file, ios::binary; vector buffer; nafasi ya int; char c; wakati ifs.readreinterpret_castposition, sizeofnafasi ifs.readc, sizeofc; string s ; ikiwa nafasi 0 s stringbuffer.begin position, buffer.end; s c; ofs.andikas.c_str, s.length; buffer.insertbuffer.end, s.begin, s.end; ifs.close; ofs.funga;int mainint argc, char argv ikiwa argc ! 4 cerr Matumizi: lz77 compressdecompress input_file output_file endl; kurudi 1; hali ya kamba argv1; string input_file argv2; string output_file argv3; ikiwa mode finyaza compresspembejeo_faili, pato_faili; vinginevyo ikiwa mode decompress decompress faili_la_pembejeo, faili_la_towe; nyengine cerr Modi ya uendeshaji si sahihi. Tumia compress au decompress. mwisho; kurudi 1; kurudi 0;Ili kuunda programu, tumia amri ifuatayo:shg -o lz77 lz77.cppBaada ya kuandaa, unaweza kuendesha programu na amri zifuatazo za compression na decompression:sh.lz77 gandamiza input.txt compressed.bin.lz77 decompressed.bin output.txtBadilisha input.txt, compressed.bin, na output.txt na majina ya faili unayotaka.Tafadhali kumbuka kuwa utekelezaji huu ni mfano rahisi wa algoriti ya LZ77 na huenda usitoe uwiano bora wa mbano. Kwa utendakazi bora, zingatia kutumia maktaba mahiri zaidi kama zlib au lz4. 