自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(14)
  • 收藏
  • 关注

原创 printd函数的编写(递归)

将一个数字作为字符串打印的情况:数字是以反序生成的,低位数字先于高位数字生成,它们必须以此相反的次序打印。 解决该问题的方法有两种。第一种方法是将生成的各个数字依次存储到一个数组中,然后以相反的次序打印他们,这种方式与前面itoa函数的处理方式相似。另一种方法是使用递归,如用printd首先调用它自身打印前面的(高位)数字,然后再打印后面的数字。 #include <stdio.h>void pri

2016-01-31 05:12:11 2334

原创 关于多重循环与break的一点疑惑

今天在调试程序的时候,想到这样一个问题,我这是一个三重循环,在最内层循环摄者一个条件,如果满足则break,那么问题是break是只中断内层循环,三重循环都中断。 for() for() for() { if(满足条件) break;

2016-01-31 01:33:20 781

原创 atof函数的编写

#include<stdio.h> #include<ctype.h> // stof函数:把字符串s转换为相应的双精度浮点数 double atof(char s[]) { double val,power; int i,sign; //去除空格 for(i = 0;isspace(s[i]);i++) ; sign = (s[i] == '

2016-01-30 22:37:59 1210

原创 trim函数的编写

#include <string.h> #include <stdio.h> //删除字符串尾部的空格符、制表符与换行符,并返回最后一个字符的下标 int trim(char s[]) { int n; for(n = strlen(s) - 1;n >= 0;n--) if(s[n] != ' '&& s[n] != '\t'&&s[n] !='\n')

2016-01-30 20:48:53 525

原创 itoa函数的编写

#include <string.h> #include <stdio.h>void reverse(char s[]) { int i,j; char temp; for(i = 0,j = strlen(s) - 1 ;i < j;i++,j--) { temp = s[i]; s[i] = s[j]; s[j] =

2016-01-30 20:05:47 508

原创 reverse函数的编写

#include <string.h> #include <stdio.h> int main() { void reverse(char s[]); char s[9] = {'1','2','3','4','5','6','7','\0'}; reverse(s); printf("%s",s); return 0; } //本函数的编写能将字符串s的字符

2016-01-30 19:30:59 1269 2

原创 swirch语句的应用

#include <stdio.h> #include <stdlib.h>int main() { int c,i,nwhrite,nother,ndight[10]; nwhrite = nother = 0; for(i = 0; i < 10;i ++) ndight[i] = 0; while((c = getchar()) != EOF)

2016-01-30 01:30:31 953

原创 else if 语句的应用

#include <stdio.h> #include <stdlib.h>int main() { int binsearch(int x,int v[],int n); int array[10] = {0,1,2,3,4,5,6,7,8,9}; printf("%d",binsearch(7,array,10)); return 0; }//else if 语句

2016-01-30 01:00:04 1102

原创 bitscount函数的重写

#include <stdio.h> #include <stdlib.h>int main() { int bitscount(unsigned x); printf("%d",bitscount(252)); return 0; }//可参照bitDelete函数(将无符号整形数最右边为1的一位删除),在上一 //篇博文有讲解 int bitscount(unsigned

2016-01-29 16:00:19 334

原创 bitDelete函数的编写

#include <stdio.h> #include <stdlib.h>int main() { int bitDelete(unsigned x); printf("%d",bitDelete(254)); return 0; }//bitDelete函数,将无符号整形数最右边为1的一位删除 int bitDelete(unsigned x) { x &= (x

2016-01-29 15:54:21 235

原创 bitscount函数的编写

#include <stdio.h> #include <stdlib.h>int main() {} //这里将x声明为无符号数,是为了保证x右移时,左边空出的位数都是用0填补 //本函数的作用是获得无符号整形数x中二进制存储方式1的个数 int bitcount(unsigned x) { int b; //这里用x和01比较,(01是八进制数),无论在怎样的机型中,其左边的数字

2016-01-29 15:07:43 548

原创 getbits函数的编写

#include <stdio.h> #include <stdlib.h>int main() { unsigned getbits(unsigned x,int p,int n); printf("%d",getbits(251,4,3)); return 0; } //该函数返回x从右边第p位开始向右边数n位,这里假定最右边的一位是第0位 unsigned getbit

2016-01-29 14:52:38 1456

原创 字符串转化为十六进制

#include <stdio.h> #include <stdlib.h> //将字符串转化为十六进制 int main() { int htoi(char s[]); char a[10] = {'3','5','B','1'}; printf("%x",htoi(a)); return 0;}int htoi(char s[]) { int i ;

2016-01-29 03:23:15 420

原创 squeeze函数编写

#include <stdio.h> #include <stdlib.h> //编写squeeze函数(s1,s2),将字符串s1中任何与s2中字符匹配的字符都删除 int test(char ch,char s2[]); void squeeze(char s1[],char s2[]); int main() { char s1[] = {'a','b','2','3','5','d',

2016-01-29 03:21:57 1271

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除