zoukankan
html css js c++ java
反转字符串
1.
#include<stdio.h>
#include<stdlib.h>
char *reverse(const char *p);
int main()
{
char *test="anihC evoL I";
char *p=reverse(test);
printf("%s",p);
free(p);
return 0;
}
char *reverse(const char *p)
{
char *dest=NULL; //空指针
int len=0,i;
char *d=""; //d 指向一块合法的地址
while(*p!='\0')
{
len++;
p++;
}
dest =(char *)malloc((len+1)*sizeof(char));
d=dest;
for(i=0;i<len;i++)
{
p--;
*d=*p;
d++;
}
return dest;
}
查看全文
相关阅读:
[2010山东ACM省赛] Balloons(搜索)
[2010山东ACM省赛] Greatest Number(数的组合+二分搜索)
[ACM] hdu 1213 How Many Tables(并查集)
C Shuffle Cards
快速读入输出模板
J Distance to Work
E Sort String
H Diff-prime Pairs
A PACM Team
区间 (interval)
原文地址:https://www.cnblogs.com/zhou2011/p/2227050.html
最新文章
Add Two Numbers
vim 常用插件的安装
LeetCode Swap Nodes in Pairs
冒泡,插入,选择,快速排序
亲密数对、递归求逆
天理工复试练习
第十章-3-结构体练习
第十章-2-结构体练习
第十章-1-结构体练习
第九章-2-指针练习
热门文章
第九章-1-指针练习
第八章-预编译处理
第六章-3-数组练习
[ACM] hdu 1754 I Hate It (线段树,单点更新)
[ACM] hdu 1166 敌兵布阵 (线段树,单点更新)
[ACM] hdu 1272 小希的迷宫(并查集)
[ACM] hdu 1198 Farm Irrigation (看图枚举+并查集)
[ACM] 携程预赛第二场 剪刀石头布(并查集)
[ACM] hdu 1241 Oil Deposits(DFS)
[ACM] poj 1182 食物链(并查集)
Copyright © 2011-2022 走看看