当前位置:网站首页>Delete some elements in the array
Delete some elements in the array
2022-07-05 17:49:00 【-Ximen blowing snow】
The requirements are described as follows
- A top-level pointer points to a structure
CCPointsArray , It's stored here n Structures - Given another structure
PointArray - from 1 Delete array from 2 Elements that meet the conditions in
The code implementation is as follows :
#include <iostream>
#include <memory>
#include <string.h>
using namespace std;
typedef struct {
int x;
int y;
} Point;
typedef struct {
Point point;
int Times;
} CCPoints;
int main() {
int n;
CCPoints aa[10];
for (int i = 0; i < 10; i++) {
aa[i].point = {
i, i};
aa[i].Times = i + 2;
}
for (int i = 0; i < 10; i++) {
cout << "i = " << i << " " << aa[i].point.x << " " << aa[i].point.y
<< " " << aa[i].Times << endl;
}
cout << endl;
const CCPoints* bb = aa;
Point tt[3];
tt[0] = {
2, 2};
tt[1] = {
4, 4};
tt[2] = {
7, 7};
auto* cc = new CCPoints[10];
for(int i = 0 ;i<10;i++){
cc[i].point = {
bb[i].point.x,bb[i].point.y};
cc[i].Times = bb[i].Times;
}
int ps2 = 0, cnts = 0;
int j = 0;
int len = 10;
for (int ps = 0; ps < 3; ps++) {
ps2 = 0;
for (int cs = 0; cs < len; cs++) {
if (cc[cs].point.x != tt[ps].x || cc[cs].point.y != tt[ps].y) {
cc[ps2] = cc[cs];
ps2++;
}else{
cnts++;
}
}
}
cout << " cnts " << cnts << endl << endl << endl;
for (int i = 0; i < len-3; i++) {
cout << " i " << cc[i].point.x << " " << cc[i].point.y << " "
<< cc[i].Times << endl;
}
delete[] cc;
}
Running results
i = 0 0 0 2
i = 1 1 1 3
i = 2 2 2 4
i = 3 3 3 5
i = 4 4 4 6
i = 5 5 5 7
i = 6 6 6 8
i = 7 7 7 9
i = 8 8 8 10
i = 9 9 9 11
cnts 3
i 0 0 2
i 1 1 3
i 3 3 5
i 5 5 7
i 6 6 8
i 8 8 10
i 9 9 11
Reference resources : Deletes the specified element from the array ——C++ Realization
边栏推荐
- QT console printout
- Independent development is a way out for programmers
- GFS分布式文件系统
- VBA drives SAP GUI to realize office automation (II): judge whether elements exist
- tkinter窗口预加载
- 论文阅读_医疗NLP模型_ EMBERT
- Action avant ou après l'enregistrement du message teamcenter
- 网络威胁分析师应该具备的十种能力
- 普通程序员看代码,顶级程序员看趋势
- Size_t 是无符号的
猜你喜欢

Ten capabilities that cyber threat analysts should have

Winedt common shortcut key modify shortcut key latex compile button

北京内推 | 微软亚洲研究院机器学习组招聘NLP/语音合成等方向全职研究员

leetcode每日一练:旋转数组

VBA drives SAP GUI to realize office automation (II): judge whether elements exist

flask接口响应中的中文乱码(unicode)处理

Thesis reading_ Medical NLP model_ EMBERT

漏洞复现----48、Airflow dag中的命令注入(CVE-2020-11978)

EPM related

Kafaka technology lesson 1
随机推荐
Tita 绩效宝:如何为年中考核做准备?
ICML 2022 | Meta提出魯棒的多目標貝葉斯優化方法,有效應對輸入噪聲
QT console printout
Server configuration jupyter environment
Knowledge points of MySQL (7)
Alpha conversion from gamma space to linner space under URP (II) -- multi alpha map superposition
What are the requirements for PMP certification? How much is it?
Oracle Recovery Tools ----oracle数据库恢复利器
Read the history of it development in one breath
较文心损失一点点性能提升很多
Compter le temps d'exécution du programme PHP et définir le temps d'exécution maximum de PHP
SQL Server(2)
Independent development is a way out for programmers
What are the changes in the 2022 PMP Exam?
ITK Example
Which platform of outer disk gold is regular and safe, and how to distinguish it?
Size_t 是无符号的
EPM相关
Complete solution instance of Oracle shrink table space
Force deduction solution summary 1200 minimum absolute difference