Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

code this algorithm in mips assembler language Algorithm 3: // read one line of text // output each word of the input line, first all

image text in transcribedcode this algorithm in mips assembler language

Algorithm 3: // read one line of text // output each word of the input line, first all words from the end, // the second time from the beginning of the line. Example: // hello world Il results in // world // hello // hello // world #include struct char terminator; // set to 0 and never changed again char line[80]; // input line } buffer: // output a text from here to here void out(char "from_here, char "to_here) { while (from_here printf(" "); // use writecrlf > // search from buffer for the next occurrence of c with given search direction char "span(char "buffer, char e, int direction) { while ("buffer=c) { if ("buffer0) return buffer: buffer += direction: } return buffer: > // return the words of the input line void rueckwaerts(char "buffer) { Il end = pointer to last character of line char Wend-buffer; while (*end!=0) end++; if (enda-buffer) return; end Il over all words char do tempespan(end,',-1); // ... search word boundary out(temp+1, end); // ... output word end-temp-1; // ... move on while (temp!-0): } "temp: // output words of the input line ahead void vorwaerts(char *buffer) { // buffer is used as local var: first pointer to first character if ("buffer=0) return; Il over all words char *temp: do temp-span(buffer.".+1); // ... determine word boundaries out(buffer, temp-1); // ... output word buffer=temp+1; // ... move on while("temp!=0); > int main(void) { fgets(buffer.line, 80, stdin); // read in a line puffer terminator=0; backward(buffer.line): forward(buffer.line): return 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Databases A Tour

Authors: Shashi Shekhar, Sanjay Chawla

1st Edition

0130174807, 978-0130174802

More Books

Students also viewed these Databases questions

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago