惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

U
Unit 42
T
Threatpost
C
CERT Recently Published Vulnerability Notes
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Security Archives - TechRepublic
Security Archives - TechRepublic
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
K
Kaspersky official blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Attack and Defense Labs
Attack and Defense Labs
N
News and Events Feed by Topic
Project Zero
Project Zero
H
Heimdal Security Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Know Your Adversary
Know Your Adversary
Google Online Security Blog
Google Online Security Blog
W
WeLiveSecurity
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Schneier on Security
Schneier on Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
N
News | PayPal Newsroom
Hacker News - Newest:
Hacker News - Newest: "LLM"
H
Hacker News: Front Page
L
LINUX DO - 热门话题
Spread Privacy
Spread Privacy
T
Threat Research - Cisco Blogs
Cloudbric
Cloudbric
V
Vulnerabilities – Threatpost
Hacker News: Ask HN
Hacker News: Ask HN
S
Securelist
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
TaoSecurity Blog
TaoSecurity Blog
NISL@THU
NISL@THU
N
News and Events Feed by Topic
S
Security Affairs
The Last Watchdog
The Last Watchdog
T
Tor Project blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
T
The Exploit Database - CXSecurity.com
Simon Willison's Weblog
Simon Willison's Weblog
P
Palo Alto Networks Blog
AWS News Blog
AWS News Blog
P
Proofpoint News Feed
C
Cisco Blogs
C
Cyber Attacks, Cyber Crime and Cyber Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
L
LINUX DO - 最新话题
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
T
Tenable Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Schneier on Security

博客园 - 周伟

域名解析文件hosts文件是什么?如何修改hosts文件? PowerDesigner 使用心得 实现TOMCAT服务下一个ip绑定多域名绑定的方法 CSV扩展类 C++导入导出CSV文件 WebService 随写 mysql相关文章收集 Linux下两种自动启动Tomcat的方法 linux自动启动mysql LINUX下mysql的大小写区分设置 Jdom使用指南 vector+struct在数据接口中的应用 UML用例中使用和扩展意义 枚举和字符串互转 单件模式的C++标准实现 设计模式 Add Crash Reporting to Your Applications with the CrashRpt Library 设计模式——单键模式(singleton)C++实现 Singleton的C++实现 及相关问题
struct+vector实现树结构
周伟 · 2009-07-02 · via 博客园 - 周伟

typedef struct tagGateInfo
{
 char GateName[20];
 int  GateValue;
}GateInfo;

typedef struct tagBeamInfo
{
 char BeamName[20];
 int BeamValue;
 vector<tagGateInfo> vGateInfo;

}BeamInfo;

typedef struct tagChannelInfo
{
 char ChannelName[20];
 int ChannelValue;
 vector<tagBeamInfo> vBeamInfo;
}ChannelInfo;

typedef struct tagDataInfo
{
 char DataName[20];
 int DataValue;
 vector<tagChannelInfo> vChannelInfo;
}DataInfo;

VectorTest::GetVector(tagDataInfo &stuDataInfo)
{
 CString strMsg = NULL;

 strMsg.Format("DataName%");
 strncpy(stuDataInfo.DataName,strMsg,strMsg.GetLength());
 stuDataInfo.DataValue = 10;

 for (int i=0;i<50;i++)
 {
  tagChannelInfo stuChannelInfo;
  memset(&stuChannelInfo,0,sizeof(tagChannelInfo));
  
  for (int j=0;j<40;j++)
  {
   tagBeamInfo stuBeamInfo;
   memset(&stuBeamInfo,0,sizeof(tagBeamInfo));
   
   for (int z = 0;z < 30;z++)
   {
    tagGateInfo stuGateInfo;
    memset(&stuGateInfo,0,sizeof(tagGateInfo));
    
    strMsg.Format("GateName%d",z);
    strncpy(stuGateInfo.GateName,strMsg,strMsg.GetLength());
    stuGateInfo.GateValue = 20+z;
    
    stuBeamInfo.vGateInfo.push_back(stuGateInfo);
   }
   
   strMsg.Format("BeamName%d",j);
   strncpy(stuBeamInfo.BeamName,strMsg,strMsg.GetLength());
   stuBeamInfo.BeamValue = 30+j;
   stuChannelInfo.vBeamInfo.push_back(stuBeamInfo);
  }
  
  strMsg.Format("ChannelName%d",i);
  strncpy(stuChannelInfo.ChannelName,strMsg,strMsg.GetLength());
  stuChannelInfo.ChannelValue = 40+i;
  stuDataInfo.vChannelInfo.push_back(stuChannelInfo);
 }
 return TRUE;
}

调用:

void CMyDlg::OnBnClickedButton3()
{
 VectorTest vectorTest;
 tagDataInfo stuDataInfo;
 memset(&stuDataInfo,0,sizeof(tagDataInfo));
 vectorTest.GetVector(stuDataInfo);

 CString strMsg = NULL;

 //Get the
 strMsg.Format("GateName of Channle4_Beam2_Gate1_____________%s",stuDataInfo.vChannelInfo[3].vBeamInfo[1].vGateInfo[1].GateName);
 MessageBox(strMsg);
 
 

 int nGateCount = stuDataInfo.vChannelInfo[3].vBeamInfo[1].vGateInfo.size();

 int GateValue = stuDataInfo.vChannelInfo[3].vBeamInfo[1].vGateInfo[nGateCount-1].GateValue;

 strMsg.Format("%s",stuDataInfo.vChannelInfo[1].ChannelName);

}