
LinuxC
文章平均质量分 55
lou__001
每天一小步,时间久了你会发现你已经走了很远
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
用C语言实现简单的计算器(加、减、乘、除)
使用一个.c文件完成加减乘除的功能 代码如下: #include int add(int a,int b); int sub(int a,int b); int mul(int a,int b); int div(int a,int b); int main() { int a; int b; char c; printf("please原创 2016-04-23 19:37:37 · 16445 阅读 · 0 评论 -
用C语言打印出杨辉三角
用C语言打印出杨辉三角 杨辉三角形是形如: 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 的三角形,其实质是二项式(a+b)的n次方展开后各项的系数排成的三角形,它的特点是左右两边全是1,从第二行起,中间的每一个数是上一行里相邻两个数之和。 代码如下: #include int main() {原创 2016-04-23 19:31:17 · 1075 阅读 · 0 评论 -
输出1~100之内的素数及素数个数简单程序
#include int main() { int i; int j; int k = 1; for(i = 1; i { if(i == 2) { printf("%d\n",i); } else {原创 2016-04-18 21:34:46 · 3930 阅读 · 0 评论 -
利用递归方法实现一个函数,该函数能够实现n的阶乘,即 n! = n*(n-1)*…*3*2*1
利用递归方法实现一个函数,该函数能够实现n的阶乘,即 n! = n*(n-1)*…*3*2*1 代码如下: #include int main() { int n; int i; int s = 1; printf("please input n:\n"); scanf("%d",&n); printf("%d!=",原创 2016-04-23 19:49:00 · 15914 阅读 · 1 评论 -
输入一个字符串,计算字符串中子串出现的次数
输入一个字符串,计算字符串中子串出现的次数 字符串:“hellosdfdshellodsfdshello” 子串:“hello” 代码如下: #include #include int main() { char * c = "hellosdfdshellodsfdshello"; char * d = "hello"; int n; in转载 2016-04-23 19:54:17 · 13737 阅读 · 3 评论 -
自定义字符串拷贝my_strcpy()
char *my_strcpy(char *dest,char *ptr) { char *temp = dest; while(*ptr != '\0') { *temp = *ptr; temp++; ptr++; } *temp = '\0'; return ptr; }原创 2017-04-26 11:29:36 · 629 阅读 · 0 评论 -
自定义字符串大小判断my_strcmp()
int my_strcmp(char *dest,char *ptr) { while(*ptr != '\0') { if(*ptr == *dest) { ptr++; dest++; } else if(*dest > *ptr)原创 2017-04-26 11:31:48 · 711 阅读 · 0 评论