码迷,mamicode.com
首页 >  
搜索关键字:assert    ( 2161个结果
将数组"student a am i"改为"i am a student".
题目:有一个字符数组的内容为:"studentaami",请你将数组的内容改为"iamastudent".要求:不能使用库函数。只能开辟有限个空间(空间个数和字符串的长度无关)。题目分析:由于题目中给定的字符串中包含空格字符,就不能简单的将数组的内容整个进行逆置,题目中要求不能使用库函..
分类:编程语言   时间:2015-11-01 19:44:13    阅读次数:193
C语言中断言ASSERT
我一直以为assert仅仅是个报错函数,事实上,它居然是个宏,并且作用并非“报错”。 在经过对其进行一定了解之后,对其作用及用法有了一定的了解,assert()的用法像是一种“契约式编程”,在我的理解中,其表达的意思就是,程序在我的假设条件下,能够正常良好的运作,其实就相当于一个if语句: if(假...
分类:编程语言   时间:2015-11-01 00:21:32    阅读次数:220
替换字符串中的空格
题目:实现一个函数,要求吧字符串中的所有空格替换成“%20”。例如“wearehappy."-->”we%20are%20happy."#include<stdio.h> #include<stdlib.h> #include<assert.h> voidstrReplace(constchar*dst,char*pun,constchar*src); intcountSpace(constchar*d..
分类:其他好文   时间:2015-10-31 18:46:41    阅读次数:240
【面试常考】C语言:输入:"student a am i",输出"i am a student,不能使用库函数
#include<stdio.h> //#include<assert.h> voidmy_reverse(char*left,char*right) { //assert(left); //assert(right);用以处理指针函数为空,保证有效 while(left<right) { chartmp=*left;//借助中间变量实现逆置 *left=*right; *right=tmp; left++; right--; }..
分类:编程语言   时间:2015-10-31 18:46:04    阅读次数:548
c语言,将字符串逆置,如"i am a student"逆置为"student a am i"
#include<stdio.h> #include<assert.h> /*求字符串长度*/ intmy_strlen(char*str) { assert(str); intcount=0; while(*str) { count++; str++; } returncount; } /*逆置函数*/ char*reverse_str(char*start,char*end) { char*ret=start; chartemp; whi..
分类:编程语言   时间:2015-10-31 18:43:19    阅读次数:200
将数组"student a am i"的内容改为"i am a student"
有一个字符数组的内容为:"studentaami",请你将数组的内容改为"iamastudent". 要求: 不能使用库函数。只能开辟有限个空间(空间个数和字符串的长度无关)。 #include<stdio.h> #include<assert.h> intmy_len(char*str) { intcount=0; assert(str); while(*st..
分类:编程语言   时间:2015-10-31 18:42:46    阅读次数:238
有一个字符数组的内容为:"student a am i",请你将数组的内容改为"i am a student".
#include<stdio.h> #include<assert.h> intlength(constchar*str) { intlen=0; assert(str); while(*str) { len++; str++; } returnlen; } voidreverse_str(char*start,char*end) { while(start<end) { chartmp=*start; *start=*end; *end=tmp; start++; end--..
分类:编程语言   时间:2015-10-31 18:41:09    阅读次数:188
python--第一天总结
【变量】1、变量定义的规则: 变量名只能是 字母、数字或下划线的任意组合 变量名的第一个字符不能是数字 以下关键字不能声明为变量名 ['and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', ...
分类:编程语言   时间:2015-10-30 22:50:32    阅读次数:288
C语言--求字符串长度的三种解法
问题:求一个字符串的三种解法一、计数的方法#include<stdio.h> #include<assert.h> intmy_strlen(char*str) { intcount=0; while(*str) { count++; str++; } returncount; } intmain(void) { char*arr="abcef"; intret=my_strlen(arr); printf("%d\n"..
分类:编程语言   时间:2015-10-26 19:01:42    阅读次数:156
java关键字
下面列出了Java保留字。这些保留字不能用于常量、变量、和任何标识符的名称。关键字描述abstract抽象方法,抽象类的修饰符assert断言条件是否满足boolean布尔数据类型break跳出循环或者label代码段byte8-bit 有符号数据类型caseswitch语句的一个条件catch和t...
分类:编程语言   时间:2015-10-24 15:35:21    阅读次数:147
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!