b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

c++ strchr函数_strchr函数返回_模拟实现strchr函数(12)

电脑杂谈  发布时间:2017-02-28 08:29:56  来源:网络整理

{

intc,j,i;

for(i=0,j=strlen(s)-1;i<j;i,j--) //完成倒置功能,不包括字符串结束符'/0'

{

c=s[i];

s[i]=s[j];

s[j]=c;

}

}

int main() //主函数,用于测试reverse函数的功能

{

chars[]="123456";

reverse(s); //调用倒置函数

printf("%s\n",s); //输出倒置后的字符串

return 0;

}

输出结果:654321

int isdigit(int ch);

检查ch是否是数字(0-9)

是返回1,否则返回0

#include <stdio.h>

#include <ctype.h>

int main()

{

char ch1='1';

char ch2='a';

if(isdigit(ch1)!=0)

printf("%c is the ASCII number\n",ch1);

else

printf("%c is not the ASCII number\n",ch1);

if(isdigit(ch2)!=0)

printf("%c is the ASCIInumber\n",ch2);

else

printf("%c is not the ASCII number\n",ch2);

return 0;

}

输出结果:

1 is the ASCII number

a is not the ASCII number

intisalpha(intch);

检查ch是否是字母

是返回1,否则返回0

#include<stdio.h>

#include<ctype.h>

int main()

{

char ch1='*';

char ch2='a';

if(isalnum(ch1)!=0)

printf("%c is the ASCII number or alphebet\n",ch1);

else

printf("%c is not the ASCII number nor alphebet\n",ch1);

if(isalnum(ch2)!=0)

printf("%c is the ASCII number or alphebet\n",ch2);

else

printf("%c is not the ASCII number nor alphebet\n",ch2);

return 0;

}

输出结果:

* is not the ASCII number nor alphabet

a is the ASCII number or alphabet

intislower(intch);

检查ch是否小写字母(a-z)

是返回1,否则返回0

extern int isupper(int c);

判断字符c是否为大写英文字母

#include <ctype.h>

#include <stdio.h>

int main()

{

char Test[]="a1B2c3D4";

char *pos;

pos=Test;

while(*pos!=0)

{

if(isupper(*pos))


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-34960-12.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...