当前位置:网站首页>(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; }
边栏推荐
- Questions d'examen écrit classiques du pointeur
- HAC集群修改管理员用户密码
- [force buckle]43 String multiplication
- Imperial cms7.5 imitation "D9 download station" software application download website source code
- 无代码六月大事件|2022无代码探索者大会即将召开;AI增强型无代码工具推出...
- UCF (summer team competition II)
- 27io stream, byte output stream, OutputStream writes data to file
- Selective parameters in MATLAB functions
- UCF (2022 summer team competition I)
- Oracle query table index, unique constraint, field
猜你喜欢
Vulhub vulnerability recurrence 71_ Unomi
[mask requirements of OSPF and Isis in multi access network]
自建DNS服务器,客户端打开网页慢,解决办法
Ad20 is set with through-hole direct connection copper sheet, and the bonding pad is cross connected
nacos-高可用seata之TC搭建(02)
Self built DNS server, the client opens the web page slowly, the solution
Vulhub vulnerability recurrence 72_ uWSGI
[cloud native] 3.1 kubernetes platform installation kubespher
How to download GB files from Google cloud hard disk
Nacos TC setup of highly available Seata (02)
随机推荐
Unity Vector3. Use and calculation principle of reflect
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
Anti shake and throttling are easy to understand
Easy to understand I2C protocol
C AES encrypts strings
JS quick start (II)
浅谈镜头滤镜的类型及作用
MySQL if and ifnull use
How to get list length
Fluent implements a loadingbutton with loading animation
Can the feelings of Xi'an version of "Coca Cola" and Bingfeng beverage rush for IPO continue?
Pointer classic written test questions
[JVM] [Chapter 17] [garbage collector]
Note the various data set acquisition methods of jvxetable
Three methods of Oracle two table Association update
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
无代码六月大事件|2022无代码探索者大会即将召开;AI增强型无代码工具推出...
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
LeetCode_字符串反转_简单_557. 反转字符串中的单词 III
Safe mode on Windows