当前位置:网站首页>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:
边栏推荐
- What is it like to trade for a living?
- Task execution control in Ansible
- Industrial control network intrusion detection based on automatic optimization of hyperparameters
- Collection of NFT tools
- BGP 第一次实验
- Disk and file system management
- A simple file transfer tools
- 辨析内存函数memset、memcmp、memmove以及memcpy
- 【21天学习挑战赛】顺序查找和二分查找的小总结
- Difference between JSP out.print() and out.write() methods
猜你喜欢
实现删除-一个字符串中的指定字母,如:字符串“abcd”,删除其中的”a”字母,剩余”bcd”,也可以传递多个需要删除的字符,传递”ab”也可以做到删除”ab”,剩余”cd”。
22. The support vector machine (SVM), gaussian kernel function
【HCIP】BGP小型实验(联邦,优化)
Arduino Basic Syntax
Don't know about SynchronousQueue?So ArrayBlockingQueue and LinkedBlockingQueue don't and don't know?
测试点等同于测试用例吗
A simple file transfer tools
Graphical LeetCode - 1161. Maximum Sum of In-Layer Elements (Difficulty: Moderate)
uni-app project summary
TCL:在Quartus中使用tcl脚本语言进行管脚约束
随机推荐
unity2D横版游戏教程5-UI
NFT工具合集
An Enhanced Model for Attack Detection of Industrial Cyber-Physical Systems
IP核:FIFO
When Netflix's NFTs Forget Web2 Business Security
短视频SEO优化教程 自媒体SEO优化技巧方法
工业信息物理系统攻击检测增强模型
nodeJs--各种路径
实现删除-一个字符串中的指定字母,如:字符串“abcd”,删除其中的”a”字母,剩余”bcd”,也可以传递多个需要删除的字符,传递”ab”也可以做到删除”ab”,剩余”cd”。
GIF making - very simple one-click animation tool
JSP如何使用page指令让JSP文件支持中文编码呢?
06-SDRAM :SDRAM控制模块
How does JSP use request to get the real IP of the current visitor?
JSP out.write()方法具有什么功能呢?
ROS 动态参数
短视频SEO搜索运营获客系统功能介绍
07-SDRAM: FIFO control module
els 长条变形
els 方块边界变形处理
JSP Taglib指令具有什么功能呢?