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

发布时间 : 星期三 文章算法与数据结构实验册(顾原翔1413101019)(1)(1)更新完毕开始阅读

金陵科技学院实验报告

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);

联系合同范文客服:xxxxx#qq.com(#替换为@)