Remove1

Error_code  List<List_entry>::remove

(int position,List_entry&x)

{

if(count==0) return underflow;

if(position<0||position>=count)

return range_error;

x=entry[position];

for (int i=position;i<=count-2;i++)

entry[i]=entry[i+1];

count--;

return success;

}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Here's an implementation of the `str_remove1`, `str_remove2`, and `main` procedures in x86 assembly language using the Irvine32 library: ``` include Irvine32.inc ; str_remove1 - Removes n characters from a string starting at a specified pointer ; Input: ESI = pointer to string ; ECX = number of characters to remove str_remove1 PROC push ebx push ecx mov ebx, esi ; save pointer to string in EBX add esi, ecx ; move pointer to end of characters to remove mov cl, [esi] ; get next character after characters to remove str_remove1_loop: mov al, [esi+1] ; copy character after current character to current position mov [esi], al inc esi cmp al, 0 ; check for end of string jne str_remove1_loop ; repeat until end of string is reached sub esi, ecx ; move pointer back to start of removed characters mov byte ptr [esi], cl ; add null terminator at end of new string mov esi, ebx ; restore pointer to original string pop ecx pop ebx ret str_remove1 ENDP ; str_remove2 - Removes n characters from a string starting at a specified position ; Input: ESI = pointer to string ; EDX = starting position ; ECX = number of characters to remove str_remove2 PROC push ebx push ecx mov ebx, esi ; save pointer to string in EBX add esi, edx ; move pointer to starting position add esi, ecx ; move pointer to end of characters to remove mov cl, [esi] ; get next character after characters to remove str_remove2_loop: mov al, [esi+1] ; copy character after current character to current position mov [esi], al inc esi cmp al, 0 ; check for end of string jne str_remove2_loop ; repeat until end of string is reached sub esi, ecx ; move pointer back to start of removed characters mov byte ptr [esi], cl ; add null terminator at end of new string mov esi, ebx ; restore pointer to original string pop ecx pop ebx ret str_remove2 ENDP main PROC ; Example usage of str_remove1 mov esi, OFFSET target INVOKE str_remove1, esi+3, 4 mov edx, OFFSET target call WriteString mov edx, OFFSET crlf call WriteString ; Example usage of str_remove2 mov esi, OFFSET target INVOKE str_remove2, esi, 3, 4 mov edx, OFFSET target call WriteString mov edx, OFFSET crlf call WriteString ; Test with different arguments mov esi, OFFSET target INVOKE str_remove1, esi+7, 4 mov edx, OFFSET target call WriteString mov edx, OFFSET crlf call WriteString mov esi, OFFSET target INVOKE str_remove2, esi, 11, 6 mov edx, OFFSET target call WriteString mov edx, OFFSET crlf call WriteString EXIT main ENDP .data target BYTE "abcxxxxdefghijklmop",0 crlf BYTE 0dh, 0ah, 0 ``` In the `main` procedure, we first demonstrate the usage of `str_remove1` and `str_remove2` to remove the "xxxx" substring from the `target` string. We then test the procedures with different arguments and display the strings before and after removing characters.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值