- 浏览: 70613 次
- 性别:
- 来自: 大连
最近访客 更多访客>>
最新评论
-
newlangwen1:
你好 我想请教个问题,我运行了一下上面的程序,结果是输入什么就 ...
C程序 对文本行进行排序
strend(s,t) 如果字符串t出现在字符串s的尾部,该函数返回0,否则返回1
#include<stdio.h> int strend(char *s,char *t); int main(){ char *s="hewawowa"; char *t="wo"; int cmp=strend(s,t); printf("%d\n",cmp); return 0; } int strend(char *s, char *t) { char *ss =s;//保存s的开头 char *tt =t;//保存t的开头 int count=0; for(;*s!='\0';s++) { ss=s; for(;*s!='\0'&&*t!='\0'&&*s==*t;s++,t++) count++; if(*s=='\0'&&*t=='\0') return 1; t=tt; s=ss; } return 0; }
另一个版本的:
#include<stdio.h> int strend(char *s,char *t); int strlen(char *s); int main(){ char *s="hewawoe"; char *t="wo"; int result=strend(s,t); if(result==0) printf("%d\n",1); else printf("%d\n",0); return 0; } int strcmp(char *s, char *t) { while(*s++==*t++) ; if(*s=='\0'||*t=='\0') return 0; else return *s-*t; } int strend(char *s, char *t) { int lens; int lent; lens = strlen(s); lent = strlen(t); s=s+(lens-lent); int cmp =strcmp(s,t); return cmp; } int strlen(char *s) { int len=0; while(*s++!='\0') len++; return len; }
发表评论
-
C程序 声明与定义的区别
2010-07-30 15:34 1303http://zhidao.baidu.com/questio ... -
C语言 函数指针 与 指针函数
2010-07-30 10:27 911指针函数是返回指针的函数,即本质是一个函数。函数返回类型是某一 ... -
C程序 命令行参数
2010-07-30 09:34 673echo.cpp #include <stdi ... -
C程序 整型数按位取反 输出结果
2010-07-29 15:16 1318#include <stdio.h> int m ... -
C程序 对文本行进行排序
2010-07-26 09:30 995#include <stdio.h> #incl ... -
C语言:malloc()函数与alloc()函数
2010-07-24 10:02 912C语言跟内存分配方式 ... -
C程序设计语言(第二版) 5-3 编写strcat()
2010-07-23 16:02 799#include<stdio.h> void ... -
C程序 关于字符串的问题
2010-07-23 15:47 677#include<stdio.h> void ... -
C程序设计语言(第二版)5-2
2010-07-22 17:13 677#include <ctype.h> #incl ... -
C程序设计语言(第二版) 4-14
2010-07-22 11:47 853定义宏swap(t, x, y)以交换t类型的两个参数 ... -
C程序设计语言(第二版) 4-13 递归版本reverse()将字符串倒置输出
2010-07-22 11:18 997编写一个递归版本的reverse()函数,将字符串倒置 ... -
C程序设计语言(第二版) 4-12
2010-07-22 10:29 1024运用printd函数的设计思想编写一个递归版本的itoa函数, ... -
C程序 递归小例子 快速排序
2010-07-22 09:26 919从执行速度来讲,下列版本的快速排序可能不是最快的,但是它是最简 ... -
C程序 递归实现将数字作为字符串输出
2010-07-21 15:47 1269将一个数字作为字符串打印的情况,数字是反序生成的:低位数字先于 ... -
C语言学习之变量存储
2010-07-21 15:14 868http://zhidao.baidu.com/questio ... -
C语言外部变量的使用以及extern的用法
2010-07-21 15:11 2197http://hi.baidu.com/%C3%E2%B7%D ... -
C语言 全局变量和局部变量
2010-07-21 15:07 1428http://hi.baidu.com/%C3%E2%B7%D ... -
C语言 extern
2010-07-21 11:20 1101在头文件中声明函数时,前面的extern可有可无,只要这些函数 ... -
C程序设计语言(第二版) 4-8 最多只压回 一个字符
2010-07-20 18:47 758#include <stdio.h> i ... -
C程序设计语言(第二版) 4-7 编写一个函数ungets(),将整个字符串压回到输入中
2010-07-20 18:38 1476#include<stdio.h> #inclu ...
相关推荐
strend
校验两个日期的先后: checkDateEarlier(strStart,strEnd) 校验字符串是否为email型: checkEmail(str) 校验字符串是否为中文: checkIsChinese(str) 计算字符串的长度,一个汉字两个字符: realLength() 校验字符...
selectStr = "Select * from teacher where t_no = '" + userID + "'"; break; case "1": selectStr = "Select * from student where s_no = '" + userID + "'"; break; case "2": selectStr = "Select * ...
<%...”, “<...”, “.*(””35%”” bgcolor>(.*))[.\n]*”, “””font-size:9pt;”” color>$2</font><br>”) response.Write hehe Function Hello(strUrl, strStart, strEnd, patrn, replS
startswith()方法 Python startswith() 方法用于检查字符串... strend –可选参数用于设置字符串检测的结束位置。 返回值 如果检测到字符串则返回True,否则返回False。 常用环境:用于IF判断 #!/usr/local/bin/pyt