当前位置:网站首页>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:

边栏推荐
猜你喜欢

When Netflix's NFTs Forget Web2 Business Security

扑克牌问题

什么是低代码(Low-Code)?低代码适用于哪些场景?

Automatic conversion of Oracle-style implicit joins to ANSI JOINs using jOOQ

Redis-消息发布订阅

Unknown CMake command “add_action_files“

众筹DAO“枯萎”的缩影:曾拍下《沙丘》未出版手稿的Spice DAO解散

【HCIP】BGP小型实验(联邦,优化)

不了解SynchronousQueue?那ArrayBlockingQueue和LinkedBlockingQueue不会也不知道吧?

双队列实现栈?双栈实现队列?
随机推荐
Pytorch seq2seq 模型架构实现英译法任务
els 方块边界变形处理
回顾历史5次经济衰退时期:这一次可能会有何不同?
路由策略
Don't know about SynchronousQueue?So ArrayBlockingQueue and LinkedBlockingQueue don't and don't know?
短视频seo搜索优化主要内容
Redis-消息发布订阅
460. LFU 缓存
工业信息物理系统攻击检测增强模型
Day11 shell脚本基础知识
SphereEx Miao Liyao: Database Mesh R&D Practice under Cloud Native Architecture
ROS dynamic parameters
When Netflix's NFTs Forget Web2 Business Security
已知中序遍历数组和先序遍历数组,返回后序遗历数组
测试用例:四步测试设计法
Short video SEO search operation customer acquisition system function introduction
How does JSP use the page command to make the JSP file support Chinese encoding?
辨析内存函数memset、memcmp、memmove以及memcpy
在不完全恢复、控制文件被创建或还原后,必须使用 RESETLOGS 打开数据库,解释 RESETLOGS.
Are test points the same as test cases?