当前位置:网站首页>(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; }
边栏推荐
- 注释、接续、转义等符号
- F12 solve the problem that web pages cannot be copied
- MySQL advanced learning summary 9: create index, delete index, descending index, and hide index
- Pointer classic written test questions
- [leetcode16] the sum of the nearest three numbers (double pointer)
- Modbus protocol communication exception
- Closure, decorator
- Ad20 is set with through-hole direct connection copper sheet, and the bonding pad is cross connected
- 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
- 算法-- 爬楼梯(Kotlin)
猜你喜欢
Vulhub vulnerability recurrence 72_ uWSGI
Excel转换为Lua的配置文件
Zoom and pan image in Photoshop 2022
Safe mode on Windows
[leetcode16] the sum of the nearest three numbers (double pointer)
Check the useful photo lossless magnification software on Apple computer
Summary of redis basic knowledge points
Three methods of Oracle two table Association update
Unity Vector3. Use and calculation principle of reflect
Yyds dry inventory SSH Remote Connection introduction
随机推荐
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
[machine learning notes] univariate linear regression principle, formula and code implementation
C进阶-数据的存储(上)
Oracle deletes duplicate data, leaving only one
Vulhub vulnerability recurrence 71_ Unomi
【OSPF 和 ISIS 在多路访问网络中对掩码的要求】
Mongodb basic knowledge summary
Notes, continuation, escape and other symbols
Modbus protocol communication exception
趋势前沿 | 达摩院语音 AI 最新技术大全
flutter 实现一个有加载动画的按钮(loadingButton)
UCF(2022暑期团队赛一)
Fluent implements a loadingbutton with loading animation
Selective parameters in MATLAB functions
[cloud native] 3.1 kubernetes platform installation kubespher
Excel转换为Lua的配置文件
UCF (summer team competition II)
JS array list actual use summary
注释、接续、转义等符号
Vulhub vulnerability recurrence 73_ Webmin