当前位置:网站首页>2.1-----27. Remove elements
2.1-----27. Remove elements
2022-08-09 02:05:00 【@ Bai Gui】
一、题目
二、代码
class Solution {
public:
int removeElement(vector<int>& nums, int val) {
//Variables are used routinely
int i=0;
int count_num_sub=0; //用于记录数组的长度
int return_count=0;
//variables in this question
int size= nums.size();
if(size!=0)
{
int another_num[size];
for(i=0;i<=size-1;i++) another_num[i]=0; //The array is declared and cleared
for(i=0;i<=size-1;i++) //依次查找 If not removed into another array
{
if(nums[i]!=val)
{
std::cout<<" i "<< i<<std::endl;
another_num[count_num_sub]=nums[i];
count_num_sub=count_num_sub+1;
}
}
return_count=count_num_sub;
//At this point the final numbers and arrays have been obtained reverse coverage
for(i=0;i<=size-1;i++) nums[i]=another_num[i]; //The array is declared and cleared
}
else return_count=0;
return return_count;
}
};
三、运行结果
边栏推荐
- OpenSceneGraph3.5.1编译
- 软件测试技术之如何编写测试用例(5)
- 全文翻译:EDPB 基于设计和默认的数据保护指南
- Wireshark packet capture tool
- class path resource [bean.xml] cannot be opened because it does not 错误解决方案
- mysql 5.7 入坑
- Docker redis master-slave replication setup, the container cannot be started?
- VOIP使用单端口替换动态端口池进行UDP通信
- 软件测试的调用接口怎么调用,逻辑是什么?
- [Signal denoising] Based on Sage-Husa adaptive Kalman filter to realize the suppression of ocean wave magnetic field noise and the generation of ocean wave magnetic field noise with matlab code
猜你喜欢
NPDP改版前最后一次考试!请注意
PMP有什么答题技巧?
Use of torchversion.transforms
torchversion.transforms的使用
力扣刷题记录5.1-----59. 螺旋矩阵 II
D. Tournament Countdown
The Best Open Source Web Application Firewall to Protect Your Web Applications
class path resource [bean.xml] cannot be opened because it does not 错误解决方案
Qt中QFile、QByteArray QDataStream和QTextStream区别
数据库设计的总结
随机推荐
OpenSceneGraph3.5.1编译
Analysis of when AuthenticationSuccessHandler is called after UsernameAuthenticationFilter is authorized successfully
Codeforces Round #809 (Div. 2)A~D1
全文翻译:EDPB关于VVA(虚拟语音助理)中处理个人数据的指南02/2021
Qt中QFile、QByteArray QDataStream和QTextStream区别
The Best Open Source Web Application Firewall to Protect Your Web Applications
Phenomenon 1 during RF debugging
2020.12.4日志
谷歌翻译下载-免费谷歌翻译软件下载
gstreamer 记录
d初化模板构造器
右键新建缺少word、excel选项问题处理
33. 分别谈谈联合索引生效和失效的条件
etcd实现大规模服务治理应用实战
Likou Brush Question Record 8.1-----206. Reverse linked list
[机缘参悟-65]:《兵者,诡道也》-6-孙子兵法解读-并战计
力扣刷题记录10.1-----19. 删除链表的倒数第 N 个结点
谷歌翻译软件-免费谷歌翻译
2022护眼产品展,北京眼健康展,眼科医学展,近视矫正设备展
typescript91-添加任务基本实现