当前位置:网站首页>指针--剔除字符串中的所有数字
指针--剔除字符串中的所有数字
2022-07-06 09:24:00 【|光|】
要求
编一个函数,剔除字符串中的所有数字。(用指针实现)
代码
#include<stdio.h>
/* * 该函数用来实现删除字符串中的所有数字 *a为指向字符串数组的指针 */
char *delete_digit(char *a)
{
int l = strlen(a);
char b[l];
int i,j=0,k;
for(i=0;i<l;i++)
{
if(a[i]>='0'&&a[i]<='9')
continue;
else
{
b[j] = a[i];
j++;
}
}
for(i=0;i<l;i++)
{
a[i] = '\0';
}
for(i=0;i<l-2;i++)
{
if(b[i]=='.')
{
if(b[i+2]>='a'&&b[i+2]<='z')
continue;
else if(b[i+2]>='A'&&b[i+2]<='Z')
continue;
else
b[i+1]='\0';
}
}
strcpy(a,b);
return a;
}
main函数
int main()
{
char a[200];
gets(a);
delete_digit(a);
puts(a);
return 0;
}
测试
测试输入
123Try234 you53r b5234est wh2435en y25ou2 are 5234young. 45324Never524 regret523.
输出
Try your best when you are young. Never regret.
边栏推荐
- Statistics 8th Edition Jia Junping Chapter 3 after class exercises and answer summary
- Statistics 8th Edition Jia Junping Chapter 10 summary of knowledge points of analysis of variance and answers to exercises after class
- Always of SystemVerilog usage_ comb 、always_ iff
- Statistics 8th Edition Jia Junping Chapter IX summary of knowledge points of classified data analysis and answers to exercises after class
- 内网渗透之内网信息收集(三)
- Binary search tree concept
- This article explains in detail how mockmvc is used in practical work
- Record an API interface SQL injection practice
- 攻防世界MISC练习区(gif 掀桌子 ext3 )
- Hackmyvm target series (3) -visions
猜你喜欢
《统计学》第八版贾俊平第二章课后习题及答案总结
How to understand the difference between technical thinking and business thinking in Bi?
xray與burp聯動 挖掘
Statistics 8th Edition Jia Junping Chapter 12 summary of knowledge points of multiple linear regression and answers to exercises after class
Hackmyvm target series (1) -webmaster
Statistics 8th Edition Jia Junping Chapter 14 summary of index knowledge points and answers to exercises after class
Database monitoring SQL execution
Statistics, 8th Edition, Jia Junping, Chapter VIII, summary of knowledge points of hypothesis test and answers to exercises after class
记一次,修改密码逻辑漏洞实战
New version of postman flows [introductory teaching chapter 01 send request]
随机推荐
SQL injection
Hackmyvm target series (7) -tron
MySQL interview questions (4)
Low income from doing we media? 90% of people make mistakes in these three points
Apache APIs IX has the risk of rewriting the x-real-ip header (cve-2022-24112)
Statistics 8th Edition Jia Junping Chapter 3 after class exercises and answer summary
网络基础详解
Web vulnerability - File Inclusion Vulnerability of file operation
Fire! One day transferred to go engineer, not fire handstand sing Conquest (in serial)
浅谈漏洞发现思路
MSF generate payload Encyclopedia
7-6 local minimum of matrix (PTA program design)
Internet Management (Information Collection)
On the idea of vulnerability discovery
数据库多表链接的查询方式
《统计学》第八版贾俊平第十一章一元线性回归知识点总结及课后习题答案
servlet中 servlet context与 session与 request三个对象的常用方法和存放数据的作用域。
Hackmyvm target series (3) -visions
《统计学》第八版贾俊平第十二章多元线性回归知识点总结及课后习题答案
Mysql的事务是什么?什么是脏读,什么是幻读?不可重复读?