当前位置:网站首页>(column 22) typical column questions of C language: delete the specified letters in the string.
(column 22) typical column questions of C language: delete the specified letters in the string.
2022-07-06 05:33:00 【boss. Peipei】
give the result as follows :
The code analysis :
#include<stdio.h> int main() { char x,f; printf(" Please enter the letter you want to delete :"); scanf("%c",&x); getchar(); // Enter after the previous input , Need to use getchar Get rid of . printf(" Please enter the string :"); while((f=getchar())!='\n') // utilize getchar Make cyclic input { if(f==x) // If there is a letter to be deleted { continue; // Skip it } else putchar(f); // If it is not the letter to be deleted , Then print } printf("\n"); return 0; }
Clean code :
#include<stdio.h> int main() { char x,f; printf(" Please enter the letter you want to delete :"); scanf("%c",&x); getchar(); printf(" Please enter the string :"); while((f=getchar())!='\n') { if(f==x) { continue; } else putchar(f); } printf("\n"); return 0; }
边栏推荐
- Remember an error in MySQL: the user specified as a definer ('mysql.infoschema '@' localhost ') does not exist
- Golang -- TCP implements concurrency (server and client)
- 03. Login of development blog project
- Vite configures the development environment and production environment
- Detailed summary of SQL injection
- Nacos - TC Construction of High available seata (02)
- [detailed explanation of Huawei machine test] check whether there is a digital combination that meets the conditions
- 26file filter anonymous inner class and lambda optimization
- Summary of redis basic knowledge points
- Can the feelings of Xi'an version of "Coca Cola" and Bingfeng beverage rush for IPO continue?
猜你喜欢
Modbus协议通信异常
剑指 Offer II 039. 直方图最大矩形面积
Deep learning -yolov5 introduction to actual combat click data set training
Nacos - TC Construction of High available seata (02)
Codeforces Round #804 (Div. 2) Editorial(A-B)
27io stream, byte output stream, OutputStream writes data to file
[leetcode daily question] number of enclaves
无代码六月大事件|2022无代码探索者大会即将召开;AI增强型无代码工具推出...
04. 项目博客之日志
Cuda11.1 online installation
随机推荐
UCF(2022暑期团队赛一)
[mask requirements of OSPF and Isis in multi access network]
Vite configures the development environment and production environment
剑指 Offer II 039. 直方图最大矩形面积
02. Develop data storage of blog project
Self built DNS server, the client opens the web page slowly, the solution
Tetris
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
备忘一下jvxetable的各种数据集获取方法
Qt TCP 分包粘包的解决方法
【LeetCode】18、四数之和
【torch】|torch.nn.utils.clip_grad_norm_
无代码六月大事件|2022无代码探索者大会即将召开;AI增强型无代码工具推出...
05. 博客项目之安全
Pickle and savez_ Compressed compressed volume comparison
C Advanced - data storage (Part 1)
Vulhub vulnerability recurrence 67_ Supervisor
应用安全系列之三十七:日志注入
[machine learning notes] univariate linear regression principle, formula and code implementation
How to download GB files from Google cloud hard disk