当前位置:网站首页>(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; }
边栏推荐
- Easy to understand IIC protocol explanation
- Jvxetable用slot植入j-popup
- 无代码六月大事件|2022无代码探索者大会即将召开;AI增强型无代码工具推出...
- SQLite queries the maximum value and returns the whole row of data
- Mongodb basic knowledge summary
- Cve-2019-11043 (PHP Remote Code Execution Vulnerability)
- Huawei equipment is configured with OSPF and BFD linkage
- In 2022, we must enter the big factory as soon as possible
- 【torch】|torch.nn.utils.clip_grad_norm_
- Jvxetable implant j-popup with slot
猜你喜欢

Check the useful photo lossless magnification software on Apple computer

PDK工艺库安装-CSMC

趋势前沿 | 达摩院语音 AI 最新技术大全

Codeforces Round #804 (Div. 2) Editorial(A-B)

注释、接续、转义等符号

Three methods of Oracle two table Association update

剑指 Offer II 039. 直方图最大矩形面积

02. Develop data storage of blog project

【OSPF 和 ISIS 在多路访问网络中对掩码的要求】

初识CDN
随机推荐
C AES encrypts strings
Nacos TC setup of highly available Seata (02)
In 2022, we must enter the big factory as soon as possible
Steady, 35K, byte business data analysis post
Vulhub vulnerability recurrence 72_ uWSGI
Modbus protocol communication exception
Game push image / table /cv/nlp, multi-threaded start
Oracle query table index, unique constraint, field
ARTS Week 25
Remember an error in MySQL: the user specified as a definer ('mysql.infoschema '@' localhost ') does not exist
Knowledge points of circular structure
初识CDN
Pix2pix: image to image conversion using conditional countermeasure networks
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
Cuda11.1 online installation
Algorithm -- climbing stairs (kotlin)
UCF (2022 summer team competition I)
Select knowledge points of structure
Fiddler installed the certificate, or prompted that the certificate is invalid
应用安全系列之三十七:日志注入