当前位置:网站首页>Realize deletion - a specified letter in a string, such as: the string "abcd", delete the "a" letter in it, the remaining "bcd", you can also pass multiple characters to be deleted, and pass "ab" can
Realize deletion - a specified letter in a string, such as: the string "abcd", delete the "a" letter in it, the remaining "bcd", you can also pass multiple characters to be deleted, and pass "ab" can
2022-08-02 00:33:00 【BSP Junior Primary School Monk】
Analysis:
The idea of this question is relatively simple, that is, store the string to be judged in a character array, and then judge one element by one in the character array. When an element is not equal to the element to be deleted, store the element inAnother character array, and so on.
Code:
/*Realize deletion - a specified letter in a string, such as: string "abcd", delete the "a" letter in it, the remaining "bcd", orIn order to pass multiple characters that need to be deleted, passing "ab" can also delete "ab" and leave "cd".*/#include#includeint main(){char str1[100], str2[100],c;int i = 0, j = 0;printf("Please enter the original string: ");scanf("%s", str1);getchar();printf("Please enter the letter to delete: ");scanf("%c", &c);for (i = 0; i < strlen(str1); i++){if (str1[i] != c){str2[j] = str1[i];j++;}}str2[j] = '\0';printf("Deleted string: %s", str2);return 0;}
Run result:
边栏推荐
- 2022/08/01 Study Notes (day21) Generics and Enums
- 玩转NFT夏季:这份工具宝典值得收藏
- 如何发现新的潜力项目?工具推荐
- 什么是低代码(Low-Code)?低代码适用于哪些场景?
- After reshipment tencent greetings to monitor if the corresponding service does not exist by sc. Exe command to add services
- MYSQL(基本篇)——一篇文章带你走进MYSQL的奇妙世界
- PHP从txt文件中读取数据的方法
- JSP out. The write () method has what function?
- 以交易为生是一种什么体验?
- 06-SDRAM : SDRAM control module
猜你喜欢
[Solution] Emqx startup under win10 reports Unable to load emulator DLL, node.db_role = EMQX_NODE__DB_ROLE = core
不了解SynchronousQueue?那ArrayBlockingQueue和LinkedBlockingQueue不会也不知道吧?
When Netflix's NFTs Forget Web2 Business Security
这 4 款电脑记事本软件,得试试
Short video SEO search operation customer acquisition system function introduction
Redis的集群模式
当奈飞的NFT忘记了Web2的业务安全
不要用jOOQ串联字符串
双队列实现栈?双栈实现队列?
Task execution control in Ansible
随机推荐
JSP out.print()和out.write()方法的不同之处
els 方块变形判断。
els block boundary deformation processing
IP Core: FIFO
Unknown CMake command “add_action_files“
An Enhanced Model for Attack Detection of Industrial Cyber-Physical Systems
Play NFT summer: this collection of tools is worth collecting
玩转NFT夏季:这份工具宝典值得收藏
短视频SEO优化教程 自媒体SEO优化技巧方法
Routing strategy
MySQL常用语句整理
Constructor, this keyword, method overloading, local variables and member variables
JSP Taglib指令具有什么功能呢?
基于超参数自动寻优的工控网络入侵检测
GIF making - very simple one-click animation tool
Grid false data injection attacks detection based on coding strategy
CRS 管理与维护
Difference between JSP out.print() and out.write() methods
06-SDRAM : SDRAM control module
bgp aggregation reflector federation experiment