迷灯的算法
来源:互联网 发布:qq号码淘宝 编辑:程序博客网 时间:2024/06/11 20:06
#include<stdio.h>#include<stdlib.h>#include<list.h>struct linked_list
{ char data; struct linked_list *next ;};struct linked_list *createlink(){ struct linked_list *head,*p; char ch; head=NULL; p=head; while(ch=getchar()!='/0') { p=(struct linked_list *)malloc(sizeof(struct linked_list)); p->data=ch; p->next=head; head=p; }return(head);
}
main(){ int t,s; struct linked_list *head[1]; for(t=0;t<2;t++) { head[t]=createlink(); s=count(head[t]); printf("count=%d/n",s); print_list(head[t]); printf("/n"); }concatenate(head[0],head[1]);s=count(head[0]);printf("count=%d/n",s);print_list(head[0]);exit(0);}concatenate(a,b)struct link_list *a,*b;{ if(a->next==NULL) a->next=b; else concatenate(a->next,b);}
void print_list(struct linked_list *head) { struct link_list *q; q=head; while(q!=NULL) { printf("%c",q->data); q=q->next; } }void count(struct linked_list *head) { struct linked_list *p; int k=0; p=head; while(p!=NULL) { k++; p=p->next; } return(k); }
- 迷灯的算法
- 【算法】算法的艺术
- [算法]算法的乐趣
- [算法]求最大公约数的算法
- 遗传算法的一般算法
- 一个不是算法的算法
- 算法(冒泡排序的算法)
- 算法(选择排序的算法)
- 【算法学习】算法的复杂度
- 算法-树的相关算法
- 算法和算法的衡量
- 算法 常见的排序算法
- 算法 常见的排序算法
- RSA算法的相关算法
- 算法一之开关灯的问题
- java算法之灯的开关问题
- 算法的定义及算法的复杂度
- 算法基础系列-算法的的选择
- 面向接口编程详解(三)——模式研究
- CLI-I-0 前言
- 图象一些算法
- 基数排序
- 千一网络发布 QuickAjax
- 迷灯的算法
- 暂停Action,返回客户端,问用户是否继续Action下面的操作
- 栈的基本算法
- 《QuickTest Professional Tutorial》读书笔记(10)
- fedora 9中文输入法
- 一道竞赛题
- jQuery DOM操作方法的简单归纳
- Wisdom of Kong Fu Panda
- Reflection in Actionscript 3.0/Flex 2