//将字符串中的字符逆序输出,但不改变字符串中的内容。

 #include <stdio.h>

 /************found************/
void fun (char *a)
{ if ( *a )
{ fun(a+) ;//使用递归进行数组的逆序输出。
/************found************/
printf("%c",*a) ;
}
} void main( )
{ char s[]="abcd";
printf("处理前字符串=%s\n处理后字符串=", s);
fun(s); printf("\n") ;
}

//已经建立了一个带头结点的单向链表,在main函数中将多次调用fun函数,每调用一次,输出链表尾部结点中的数据,并释放该结点,使链表缩短。

 #include    <stdio.h>
#include <stdlib.h>
#define N 8
typedef struct list//定义一个结构体
{ int data;
struct list *next;
} SLIST; void fun( SLIST *p)
{ SLIST *t, *s;
t=p->next; s=p;
while(t->next != NULL)
{ s=t;
/**********found**********/
t=t->next;
}
/**********found**********/
printf(" %d ",*t);//或者t->data
s->next=NULL;
/**********found**********/
free(t);//释放
}
SLIST *creatlist(int *a)
{ SLIST *h,*p,*q; int i;
h=p=(SLIST *)malloc(sizeof(SLIST));
for(i=; i<N; i++)
{ q=(SLIST *)malloc(sizeof(SLIST));
q->data=a[i]; p->next=q; p=q;
}
p->next=;
return h;
}
void outlist(SLIST *h)
{ SLIST *p;
p=h->next;
if (p==NULL) printf("\nThe list is NULL!\n");
else
{ printf("\nHead");
do { printf("->%d",p->data); p=p->next; } while(p!=NULL);
printf("->End\n");
}
}
void main()
{ SLIST *head;
int a[N]={,,,,,,,};
head=creatlist(a);//创建头结点
printf("\nOutput from head:\n"); outlist(head);
printf("\nOutput from tail: \n");
while (head->next != NULL){
fun(head);
printf("\n\n");
printf("\nOutput from head again :\n"); outlist(head);
}
}

最新文章

  1. javascript_this的用法
  2. Java小陷阱
  3. MVC小系列(十三)【全局异常处理与异常日志】
  4. 分页技术之PageDataSource类
  5. 一维DFT
  6. [Asp.net]常见word,excel,ppt,pdf在线预览方案(转)
  7. 源码安装apache及配置转发
  8. nyoj587 hdu1045 简单深搜
  9. vim 基本命令入门
  10. 「SCOI2015」小凸玩密室 解题报告
  11. 稳压二极管&amp;TVS二极管
  12. Struts2不扫描jar包中的action
  13. Html.RenderPartial(&quot;&quot;)与Html.Partial(&quot;&quot;)区别
  14. as3 单例的不常见写法
  15. Oracle - 为子查询提供动态结果集
  16. R语言学习笔记—决策树分类
  17. Gson 解析JSON数据
  18. Shell输出颜色设置
  19. nginx keepalive 双机
  20. 灯塔AOI简易实现

热门文章

  1. python setup.py 安装和卸载 的正确姿势
  2. 使用Powershell开机启动隐藏窗口的程序
  3. C#中获取时间戳
  4. HTTPSConnectionPool(host=&#39;files.pythonhosted.org&#39;, port=443): Read timed out的解决方法
  5. html div四边阴影效果
  6. 第四十六篇 入门机器学习——kNN - k近邻算法(k-Nearest Neighbors)
  7. selenium自动化之加载浏览器配置文件
  8. rke安装k8s cluster配置
  9. 【C语言】请输入一个n(n&lt;=10)并输出一个n行n列的杨辉三角
  10. 【visio】数据可视化 - 形状数据