亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如下具體所示,求數據結構高手指點

如下具體所示,求數據結構高手指點

Cats萌萌 2022-03-19 09:05:07
小弟剛剛自學數據結構遇到2個難題還望高手指點明路啊!!int StrReplace(SeqString* r1,int i,SeqString* r2)/*用串r2 替換串r1中自第i個字符開始,長度與r2相等的子串*/int StrCmp(SeqString* r1,SeqString* r2)/*比較兩個字符串的大小。字符的大小是由該字符在ASCII碼及國標碼中出現的先后次序確定,出現在前的字符小于出現在后的字符。串的大小通常是按字典序定義*/能幫我填一下代碼嗎!!!!!
查看完整描述

3 回答

?
萬千封印

TA貢獻1891條經驗 獲得超3個贊

int strcmp(const char * cs,const char * ct)
{
register signed char __res;
while (1) {
if ((__res = *cs - *ct++) != 0 || !*cs++)
break;
}
return __res;
}
//要考慮str2超長的情況,如果超過了str1長度,那么只替換到str1的末尾位置,其余部分不在替換,返回替換串的長度
int strreplace(char* str1 , int i , char* str2)
{
int c = i;
char *p = str1;
while(c--)
p++;
while(p)
p++ = str2++;
return i-strlen(str2);
}



查看完整回答
反對 回復 2022-03-23
?
絕地無雙

TA貢獻1946條經驗 獲得超4個贊

參考恢復代碼
#include<stdio.h>
#include<malloc.h>
#include<stdlib.h>
struct
node
{
char
data;
struct
node
*lchild;
struct
node
*rchild;
};
void
Createbitree(node*
root)
{
char
ch=getchar();
fflush(stdin);
if(ch!='#')
{
root=(node*)malloc(sizeof(node));
root->data=ch;
Createbitree(root->lchild);
Createbitree(root->rchild);
}
return;
}
void
Readbittree(node
*root)
{
printf("%c",root->data);
if(root->lchild!=NULL)
{
Readbittree(root->lchild);
}

if(root->rchild!=NULL)
{
Readbittree(root->rchild);
}
return;
}
int
main()
{
printf("輸入內容");
//創建根節點
node*
b
=
NULL;
Createbitree(b);
system("pause");
//輸出
return
0;
}



查看完整回答
反對 回復 2022-03-23
?
慕神8447489

TA貢獻1780條經驗 獲得超1個贊

是個建立二叉樹的程序。你這個兩句:
root->lchild=create
bitree();

root->rchild=create
bitree();是遞歸,調用create
bitree函數,但是你有返回值root卻沒有在create函數前面寫上其類型int、float或char,也沒有形參的設定、

查看完整回答
反對 回復 2022-03-23
  • 3 回答
  • 0 關注
  • 196 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號