当前位置:网站首页>Pointer -- eliminate all numbers in the string
Pointer -- eliminate all numbers in the string
2022-07-06 14:36:00 【|Light|】
requirement
Make up a function , Eliminate all numbers in the string .( Use a pointer to achieve )
Code
#include<stdio.h>
/* * This function is used to delete all numbers in the string *a Is a pointer to a string array */
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 function
int main()
{
char a[200];
gets(a);
delete_digit(a);
puts(a);
return 0;
}
test
Test input
123Try234 you53r b5234est wh2435en y25ou2 are 5234young. 45324Never524 regret523.
Output
Try your best when you are young. Never regret.
边栏推荐
- 使用 flask_whooshalchemyplus jieba实现flask的全局搜索
- 【指针】求二维数组中最大元素的值
- Function: calculates the number of uppercase letters in a string
- Statistics, 8th Edition, Jia Junping, Chapter 11 summary of knowledge points of univariate linear regression and answers to exercises after class
- JDBC read this article is enough
- Build domain environment (win)
- Bing Dwen Dwen official NFT blind box will be sold for about 626 yuan each; JD home programmer was sentenced for deleting the library and running away; Laravel 9 officially released | Sifu weekly
- JDBC看这篇就够了
- Load balancing ribbon of microservices
- MSF generate payload Encyclopedia
猜你喜欢
《统计学》第八版贾俊平第十四章指数知识点总结及课后习题答案
Harmonyos application development -- address book management system telmanagesys based on listcontainer [phonebook][api v6]
《统计学》第八版贾俊平第十三章时间序列分析和预测知识点总结及课后习题答案
Network layer - simple ARP disconnection
Apache APIs IX has the risk of rewriting the x-real-ip header (cve-2022-24112)
Solutions to common problems in database development such as MySQL
Record once, modify password logic vulnerability actual combat
《统计学》第八版贾俊平第三章课后习题及答案总结
Realize applet payment function with applet cloud development (including source code)
Statistics, 8th Edition, Jia Junping, Chapter 6 Summary of knowledge points of statistics and sampling distribution and answers to exercises after class
随机推荐
Database monitoring SQL execution
Apache APIs IX has the risk of rewriting the x-real-ip header (cve-2022-24112)
Uibutton status exploration and customization
Realize applet payment function with applet cloud development (including source code)
Attack and defense world misc practice area (GIF lift table ext3)
Build domain environment (win)
Sqqyw (indifferent dot icon system) vulnerability recurrence and 74cms vulnerability recurrence
[paper reproduction] cyclegan (based on pytorch framework) {unfinished}
Internet Management (Information Collection)
Intranet information collection of Intranet penetration (5)
ES全文索引
[pointer] use the insertion sorting method to arrange n numbers from small to large
Matplotlib绘图快速入门
攻防世界MISC练习区(gif 掀桌子 ext3 )
Fundamentals of digital circuit (IV) data distributor, data selector and numerical comparator
Statistics 8th Edition Jia Junping Chapter 3 after class exercises and answer summary
【指针】求二维数组中最大元素的值
Ucos-iii learning records (11) - task management
Statistics, 8th Edition, Jia Junping, Chapter VIII, summary of knowledge points of hypothesis test and answers to exercises after class
Always of SystemVerilog usage_ comb 、always_ iff