第一范文网 - 专业文章范例文档资料分享平台

算法与数据结构实验册(顾原翔1413101019)(1)(1)

来源:用户分享 时间:2025/5/19 21:15:45 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

金陵科技学院实验报告

printf(\

printf(\ scanf(\ for(i=0;i

printf(\ break; }

if(i>=s.curlen) printf(\}

(2)#include

#define maxsize 100 typedef struct{ char ch[maxsize]; int curlen; }seqstring; main(){ int i,flag=0; char ch;

seqstring s={{\ for(i=0;i

printf(\ scanf(\ for(i=0;i

printf(\ flag=1;

金陵科技学院实验报告

} if(flag==0)

printf(\}

(3)#include

#define maxsize 100 typedef struct{ char ch[maxsize]; int length; }seqstring; main(){

seqstring s={{\ int i,k; int m=s.length,j;

printf(\ for(i=0;i<=s.length;i++) printf(\

printf(\ scanf(\ if(i>m-1||i+k>m){ printf(\ return ; }

for(j=i+k;j<=i+m-1;j++) s.ch[j-k]=s.ch[j]; s.length=s.length-k;

printf(\ for(i=0;i<=s.length;i++) printf(\

金陵科技学院实验报告

}

2. #include

#include typedef struct _ChNode { int ch;

struct _ChNode *next; } ChNode;

ChNode* cncreate(const char *str) {

ChNode *head = NULL, *tail, *node; while (*str) {

node = (ChNode *)malloc(sizeof(ChNode)); node->ch = *str; node->next = NULL; if (head == NULL) {

head = node; tail = node; }

tail->next = node; tail = node; str++; }

return head; }

ChNode* cnchr(ChNode *node, int ch) {

金陵科技学院实验报告

while (node) {

if (node->ch == ch) {

return node; }

node = node->next; }

return NULL; }

ChNode* cntail(ChNode *node) {

while (node->next) {

node = node->next; }

return node; }

void cnins(ChNode *a, ChNode *b) {

ChNode *btail = cntail(b); btail->next = a->next; a->next = b; }

void cncat(ChNode *a, ChNode *b, int ch) {

ChNode *node = cnchr(a, ch); if (node == NULL) {

node = cntail(a);

算法与数据结构实验册(顾原翔1413101019)(1)(1).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c19ubg6kygh4zk8m0hvkq6k2tg1xudp00s3b_11.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top