Question

In: Computer Science

Need to code this is assembly language. Using the windows32 framework, write a procedure to read...

Need to code this is assembly language.
Using the windows32 framework, write a procedure to read a string and
shift each character of the string by one. As an example, if your input string is Abcz,
your output should be Bcda. Note that you must test your string for non-alphabetic
characters (such as numbers and special characters). If there are non-alphabetic characters, you should terminate your program with an appropriate message. You should
display your converted string using the output macro.
Hint: Let your procedure returns an empty string, if the parameter is not valid. Then
depending on the return value, print an appropriate message in your main procedure.

Solutions

Expert Solution

Given, a string S of only small English letters. We need to transform the string by making some number of moves (any number of times) to get the string “abcdefghijklmnopqrstuvwxyz†as a subsequence in that string. In one move, you can replace any character of the string to next character in alphabetical order i.e. ‘a’ can be replaced by ‘b’, ‘b’ can be replaced by ‘c’ and so on. Letter ‘z’ cannot be replaced by any character. If it is not possible to get the subsequence out of that string, then print “Not Possibleâ€.

Examples:

Input : aaaaaaaaaaaaaaaaaaaaaaaaaa Output : abcdefghijklmnopqrstuvwxyz Explanation: Second occurrence of letter 'a' will be replaced by 'b', third occurrence of letter 'a' will be first replaced by 'b' and then by 'c' and so on.

using namespace std;

// function to transform string with string

// passed as reference

bool transformString(string& s)

{

// initializing the variable ch to 'a'

char ch = 'a';

// if the length of string is less than

// 26, we can't obtain the required

// subsequence

if (s.size() < 26)

return false;

for (int i = 0; i < s.size(); i++) {

// if ch has reached 'z', it means we have

// transformed our string such that required

// subsequence can be obtained

if (int(ch) > int('z'))

break;

// current character is not greater than ch,

// then replace it with ch and increment ch

if (s[i] <= ch) {

s[i] = ch;

ch = char(int(ch) + 1);

}

}

if (ch <= 'z')

return false;

return true;

}

// Driver Code

int main()

{

string str = "aaaaaaaaaaaaaaaaaaaaaaaaaa";

if (transformString(str))

cout << str << endl;

else

cout << "Not Possible" << endl;

return 0;

}


Related Solutions

Using the windows 32 framework , write an assembly language program ; write a procedure to...
Using the windows 32 framework , write an assembly language program ; write a procedure to read a string and shift each character of the string by one. As an example, if your input string is Abcz, your output should be Bcda. Note that you must test your string for non-alphabetic characters (such as numbers and special characters). If there are non-alphabetic characters, you should terminate your program with an appropriate message. You should display your converted string using the...
write a program for the microcontroller-msp430fr6989 using code composer studio not assembly language. write a code...
write a program for the microcontroller-msp430fr6989 using code composer studio not assembly language. write a code that transmits a single character and lights the red LED upon receiving that character. The board will "talk" to itself. The green LED should turn on whenever a message is sent and the LCD will display the message being received.
Using the windows32 framework, write a procedure to read a string and shift each character of...
Using the windows32 framework, write a procedure to read a string and shift each character of the string by one. As an example, if your input string is Abcz, your output should be Bcda. Note that you must test your string for non-alphabetic characters (such as numbers and special characters). If there are non-alphabetic characters, you should terminate your program with an appropriate message. You should display your converted string using the output macro. Hint: Let your procedure returns an...
Assembly Language. Write a procedure that reverses order of a 1-D array using the stack. The...
Assembly Language. Write a procedure that reverses order of a 1-D array using the stack. The array is a string array, and the address along with the number of elements are passed through the stack. Then write a complete program to test your procedure.
Using x86 assembly language, create a flowchart and write an example of code that will sort...
Using x86 assembly language, create a flowchart and write an example of code that will sort 2 arrays of unsigned doubleword integers in ascending order and output the largest element in each array. Any sorting procedure can be used, but this procedure must be called twice for each array. The first time it is called, the first array should be sorted and the second time it is called, the second array must be sorted. As well as outputting which is...
using Windows 32 bit framework , Write an assembly language program to find the second minimum...
using Windows 32 bit framework , Write an assembly language program to find the second minimum element (formally, second minimum is larger than the minimum but smaller than all the other elements in the array) of an array of size 100. Note: You can define the array as nbrArray DWORD 23 45 21 67 78 95 dup(?) and show that your program works for the first five elements. Display the second minimum in a message box using Input output macro
Given the below pseudocode, write the proper code that implements it using MARIE's assembly language:               ...
Given the below pseudocode, write the proper code that implements it using MARIE's assembly language:                    Input a number and store it in X; if X > 1 then    Y := X + X;    X := 0; endif; Y := Y + 1; Output the value of Y; N.B: You should include the MARIE code in your Answer, with an explanation of each instruction in your code beside it. Example:              Subt One         /Subtract 1 from AC Add a...
write the code of 4 digit 7-segment display using arduino uno in assembly language by using...
write the code of 4 digit 7-segment display using arduino uno in assembly language by using software AVR STUDIO 5.1?
Write hack assembly language code for eq lt gt
Write hack assembly language code for eq lt gt
write a assembly language program to convert GRAY to BCD code in 8051
write a assembly language program to convert GRAY to BCD code in 8051
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT