2016年12月15日学习总结----字符串截取程序
来源:互联网 发布:淘宝网情趣女模特名字 编辑:程序博客网 时间:2024/05/18 05:52
#include <stdio.h>
#include <string.h>
#define MAX_SIZE 1024
char den[MAX_SIZE];
void pick_string(char *src,char *h_src,char *t_src)
{
int i;
int j;
int k;
int m = 0;
int count = 0;
int h_mark;
int t_mark;
int temp;
int h_len = strlen(h_src);
int t_len = strlen(t_src);
for(i = 0;src[i] != '\0';i++)
{
temp = i;
for(j = 0;h_src[j] != '\0';j++)
{
if(src[i] == h_src[j])
{
count++;
}
i++;
}
if(count == h_len)
{
h_mark = temp;
}
count = 0;
i = temp;
}
for(i = 0;src[i] != '\0';i++)
{
temp = i;
for(k = 0;t_src[k] != '\0';k++)
{
if(src[i] == t_src[k])
{
count++;
}
i++;
}
if(count == t_len)
{
t_mark = temp + t_len - 1;
}
count = 0;
i = temp;
}
for(i = h_mark;i <= t_mark;i++)
{
den[m] = src[i];
m++;
}
den[m] = '\0';
}
int main()
{
char src[MAX_SIZE];
char h_src[MAX_SIZE];
char t_src[MAX_SIZE];
printf("please input whole string:\n");
gets(src);
printf("please input head frame that you pick from the string:\n");
gets(h_src);
printf("please input tail frame that you pick from the string:\n");
gets(t_src);
pick_string(src,h_src,t_src);
printf("the string you pick from primary string is:%s\n",den);
return 0;
}
#include <string.h>
#define MAX_SIZE 1024
char den[MAX_SIZE];
void pick_string(char *src,char *h_src,char *t_src)
{
int i;
int j;
int k;
int m = 0;
int count = 0;
int h_mark;
int t_mark;
int temp;
int h_len = strlen(h_src);
int t_len = strlen(t_src);
for(i = 0;src[i] != '\0';i++)
{
temp = i;
for(j = 0;h_src[j] != '\0';j++)
{
if(src[i] == h_src[j])
{
count++;
}
i++;
}
if(count == h_len)
{
h_mark = temp;
}
count = 0;
i = temp;
}
for(i = 0;src[i] != '\0';i++)
{
temp = i;
for(k = 0;t_src[k] != '\0';k++)
{
if(src[i] == t_src[k])
{
count++;
}
i++;
}
if(count == t_len)
{
t_mark = temp + t_len - 1;
}
count = 0;
i = temp;
}
for(i = h_mark;i <= t_mark;i++)
{
den[m] = src[i];
m++;
}
den[m] = '\0';
}
int main()
{
char src[MAX_SIZE];
char h_src[MAX_SIZE];
char t_src[MAX_SIZE];
printf("please input whole string:\n");
gets(src);
printf("please input head frame that you pick from the string:\n");
gets(h_src);
printf("please input tail frame that you pick from the string:\n");
gets(t_src);
pick_string(src,h_src,t_src);
printf("the string you pick from primary string is:%s\n",den);
return 0;
}
0 0
- 2016年12月15日学习总结----字符串截取程序
- 2016年12月15日学习总结----阶段总结
- 2016年11月25日学习总结----程序
- 2016年12月14日学习总结----位运算程序
- 2016年12月19日学习总结----C语言程序优化
- 2016年12月4日学习总结----阶段总结
- 2016年12月11日学习总结----阶段总结
- 2016年11月15日学习总结
- 2016年11月12日学习总结
- 英语学习总结-破剑式-2016年12月9日
- 2016年12月17日学习总结----运算符
- 2016年12月18日学习总结----关键字
- 2016年12月22日学习总结----结构体
- 2016年11月26日学习总结----scanf输入带空格字符串
- 接收字符串,截取字符串,写入静态页面的程序【10月16日】
- 2016年11月27日学习总结----阶段总结
- 2016年12月31日总结
- 12月15日总结
- ScrollView内嵌GridView的事件处理
- 1619-7 张良 十二月十五号总结 [连续第七十六天]
- 【解决】Eclipse无法打开提示could not open jvm.cfg错误
- 如何禁止指定应用程序联网
- CSS学习
- 2016年12月15日学习总结----字符串截取程序
- 开源协议
- iOS配置HTTPS
- UnicodeEncodeError: 'ascii' codec can't encode characters in position问题
- C++调用IDL程序的做法(三)
- Python学习笔记 --- repr函数介绍
- HTML5
- Unity项目资源加载与管理
- Mybatis为实体类定义别名typeAliases