当前位置:网站首页>(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; }
边栏推荐
- 指针经典笔试题
- Using stopwatch to count code time
- Jvxetable用slot植入j-popup
- Knowledge points of circular structure
- Three methods of Oracle two table Association update
- MySQL if and ifnull use
- LeetCode_字符串反转_简单_557. 反转字符串中的单词 III
- 59. Spiral matrix
- 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
- [cloud native] 3.1 kubernetes platform installation kubespher
猜你喜欢

PDK工艺库安装-CSMC

26file filter anonymous inner class and lambda optimization

Using stopwatch to count code time

flutter 实现一个有加载动画的按钮(loadingButton)

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

Questions d'examen écrit classiques du pointeur

js Array 列表 实战使用总结
![[leetcode daily question] number of enclaves](/img/6e/1da0fa5c7d1489ba555e4791e2ac97.jpg)
[leetcode daily question] number of enclaves

Ora-01779: the column corresponding to the non key value saving table cannot be modified
![[mask requirements of OSPF and Isis in multi access network]](/img/7d/1ba80bb906caa9be4bef165ac26d2c.png)
[mask requirements of OSPF and Isis in multi access network]
随机推荐
Pix2pix: image to image conversion using conditional countermeasure networks
应用安全系列之三十七:日志注入
Modbus protocol communication exception
How to get list length
LeetCode_字符串反转_简单_557. 反转字符串中的单词 III
02. 开发博客项目之数据存储
Mysql高级篇学习总结9:创建索引、删除索引、降序索引、隐藏索引
MySQL time processing
C# AES对字符串进行加密
Zoom and pan image in Photoshop 2022
UCF (summer team competition II)
Imperial cms7.5 imitation "D9 download station" software application download website source code
备忘一下jvxetable的各种数据集获取方法
February 12 relativelayout
Implementing fuzzy query with dataframe
Figure database ongdb release v-1.0.3
Vulhub vulnerability recurrence 67_ Supervisor
浅谈镜头滤镜的类型及作用
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
Hyperledger Fabric2. Some basic concepts of X (1)