4.5题目: 输入一个字符串,同时输入帧头和帧尾(可以是多个字符),将该字符串中合法的帧识别出来.
来源:互联网 发布:上海犇迩网络骗局 编辑:程序博客网 时间:2024/04/29 04:47
/*题目: 输入一个字符串,同时输入帧头和帧尾(可以是多个字符),将该字符串中合法的帧识别出来.提示:帧头和帧尾分别是head和tail 字串”asdheadhauboisoktail”中headhauboisoktail是合法帧*/
#include <stdio.h>
#include <string.h>
int fun(char *ptr,char *head,char *tail)
{
char *temp;
while(*ptr != '\0')
{
if(strncmp(ptr,head,strlen(head)) == 0)
{
temp = ptr;
ptr+=strlen(head);
while(*ptr != '\0')
{
if(strncmp(ptr,tail,strlen(tail)) == 0)
{
*(ptr+strlen(tail)) = '\0';
printf("%s\n",temp);
return 0;
}
ptr++;
}
printf("find head not find tail!\n");
break;
}
else
ptr++;
}
return 0;
}
int main()
{
char src[100];
char head[20];
char tail[20];
printf("please input string:\n");
scanf("%s",src);
printf("please input head:\n");
scanf("%s",head);
printf("please input tail:\n");
scanf("%s",tail);
printf("the result:\n");
fun(src,head,tail);
return 0;
}
#include <stdio.h>
#include <string.h>
int fun(char *ptr,char *head,char *tail)
{
char *temp;
while(*ptr != '\0')
{
if(strncmp(ptr,head,strlen(head)) == 0)
{
temp = ptr;
ptr+=strlen(head);
while(*ptr != '\0')
{
if(strncmp(ptr,tail,strlen(tail)) == 0)
{
*(ptr+strlen(tail)) = '\0';
printf("%s\n",temp);
return 0;
}
ptr++;
}
printf("find head not find tail!\n");
break;
}
else
ptr++;
}
return 0;
}
int main()
{
char src[100];
char head[20];
char tail[20];
printf("please input string:\n");
scanf("%s",src);
printf("please input head:\n");
scanf("%s",head);
printf("please input tail:\n");
scanf("%s",tail);
printf("the result:\n");
fun(src,head,tail);
return 0;
}
0 0
- 4.5题目: 输入一个字符串,同时输入帧头和帧尾(可以是多个字符),将该字符串中合法的帧识别出来.
- 题目:输入一个字符串,同时输入帧头和帧尾(可以是多个字符),将该字符串中合法的帧识别出来.
- 输入一个字符串,同时输入帧头和帧尾(可以是多个字符),将该字符串中合法的帧识别出来.
- 输入一个字符串,同时输入帧头和帧尾(可以是多个字符),将该字符串中合法的帧识别出来。
- 输入一个字符串,同时输入帧头和帧尾(可以是多个字符),将该字符串中合法的帧识别出来.
- 输入一个字符串,同时输入帧头和帧尾(可以是多个字符),将该字符串中合法的帧识别出来.
- 题目:输入一个字符串,同时输入帧头和帧尾(可以是多个字符),将该字符串中合法的帧识别出来. 提示:帧头和帧尾分别是head和tail 字符串”asdheadhauboisoktail”中headha
- 输入一个字符串,同时输入帧头和帧尾(可以是多个字符),将该字符串中合法的帧识别出来. 提示:帧头和帧尾分别是head和tail 字符串”asdheadhauboisoktail”中headhaubo
- 输入一个字符串,同时输入帧头和帧尾(可以是多个字符),将该字符串中合法的帧识别出来. 提示:帧头和帧尾分别是head和tail 字符串”asdheadhauboisoktail”中headhau
- 输入一个字符串,同时输入帧头和帧尾(可以是多个字符),将该字符串中合法的帧识别出来. 提示:帧头和帧尾分别是head和tail 字符串”asdheadhauboisoktail”中headhau
- 输入一个字符串,同时输入帧头和帧尾
- 输入一个字符串 在输入帧头 帧尾 取合法帧 (标志位的使用)
- 题目:输入一个字符串,打印出该字符串中字符的所有排列。例如输入字符串abc,则输出由字符a、b、c所能排列出来的所有字符串abc、acb、bac、bca、cab和cba。
- 简单LinuxC程序关于实现识别字符串中合法的帧(字符串输入)
- 题目:输入一个字符串,输出该字符串中字符的所有组合
- 输入一个字符串,求出该字符串包含的字符集合
- 输入一个字符串,按字典序打印出该字符串中字符的所有排列。例如输入字符串abc,则打印出由字符a,b,c所能排列出来的所有字符串(剑指offer)
- <Java>随意输入字符串,如果含有"$"将该字符及之前一个字符的去掉
- 标准库类型deque
- VS2010添加包含目录和库目录
- 开发接口的正确姿势
- 20170403_Windows网络编程视频学习1
- 4.3 详解table
- 4.5题目: 输入一个字符串,同时输入帧头和帧尾(可以是多个字符),将该字符串中合法的帧识别出来.
- STM32F103个人学习基础篇(1)
- js断点调试心得(Chrome浏览器)
- 【蓝桥】 算法训练 最大最小公倍数
- 蓝桥杯模拟赛--字符串比较
- 8.Lock&Condition实现线程同步通信
- 组合数的奇偶性判断
- Fibonacci数
- hihocoder 1488 排队接水