C++ boost 解析 Json



property_tree可以解析ini,xml,json,info等格式的文本
以下示例是解析json格式的文本

#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <time.h>using namespace std;
using namespace boost::property_tree;const string file_path = "c:\\test.txt";void write_json_data_into_file(void)
{printf("%s\n","write json data");boost::property_tree::ptree root, items;boost::property_tree::ptree item1;item1.put("ID","1");item1.put("Name","wang");items.push_back(std::make_pair("1",item1));boost::property_tree::ptree item2;item2.put("ID","2");item2.put("Name","zhang");items.push_back(std::make_pair("2",item2));root.put_child("users",items);boost::property_tree::write_json(file_path,root);
}void read_json_data_from_file(void)
{printf("%s\n","read json data");boost::property_tree::ptree root;boost::property_tree::ptree items;boost::property_tree::read_json<boost::property_tree::ptree>(file_path,root);items = root.get_child("users");for(boost::property_tree::ptree::iterator it=items.begin(); it != items.end(); ++it){string key=it->first;//key IDstring ID=it->second.get<string>("ID");string Name=it->second.get<string>("Name");cout<<"key: "<<key.c_str()<<'\t';printf("ID: %s    Name: %s",ID.c_str(), Name.c_str());cout<<endl;cout<<"ID:"<<ID<<'\t'<<"Name:"<<Name<<endl;}cout<<"success"<<endl;
}void write_json_data_into_string(void)
{boost::property_tree::ptree item;item.put("a","2");std::stringstream is;boost::property_tree::write_json(is,item);std::string s = is.str();cout<<"json s:"<<s<<endl;
}void read_json_data_from_string(void)
{/*C++ 中 字符串形式的json串 需要使用 \ 转义 双引号*/std::string str_json = "{\"count\":10,\"people\":[{ \"firstName\": \"Brett\", \"lastName\":\"McLaughlin\", \"email\": \"aaaa\" },{ \"firstName\": \"Jason\", \"lastName\":\"Hunter\", \"email\": \"bbbb\"},{ \"firstName\": \"Elliotte\", \"lastName\":\"Harold\", \"email\": \"cccc\" }]}";std::stringstream str_stream(str_json);boost::property_tree::ptree root;boost::property_tree::read_json(str_stream,root);root.put("upid","001");// 插入一个数组boost::property_tree::ptree exif_array;boost::property_tree::ptree array1, array2, array3;array1.put("Make", "NIKON");array2.put("DateTime", "2011:05:31 06:47:09");array3.put("Software", "Ver.1.01");//   exif_array.push_back(std::make_pair("Make", "NIKON"));//   exif_array.push_back(std::make_pair("DateTime", "2011:05:31 06:47:09"));//   exif_array.push_back(std::make_pair("Software", "Ver.1.01"));exif_array.push_back(std::make_pair("", array1));exif_array.push_back(std::make_pair("", array2));exif_array.push_back(std::make_pair("", array3));root.put_child("exifs", exif_array);std::stringstream str_stream_temp;boost::property_tree::write_json(str_stream_temp, root);//write_json(str_stream_temp, root);std::string str = str_stream_temp.str();cout<<str<<endl;
}void testMsg(void)
{string str_json = "{\"TEST\":\"\",\"MSG\":\"130\",\"TKT\":[{\"DTYP\":\"T\",\"STOT\":\"1\",\"SNUM\":\"1\",\"CPN\":[{\"CNBR\":\"1\",\"DDAT\":\"090117\",\"DTME\":\"1205\",\"ADAT\":\"090117\",\"ATME\":\"1340\",\"ORIG\":\"TSA\",\"DEST\":\"PVG\",\"ALC1\":\"FM\",\"FLTN\":\"802\",\"CLAS\":\"Y\",\"FSTN\":\"OK\",\"FBAS\":\"Y\",\"BAGA\":\"20K\"}]}]}";std::stringstream str_stream(str_json);boost::property_tree::ptree root;boost::property_tree::read_json(str_stream,root);boost::property_tree::ptree::iterator root_it = root.begin();for(; root_it != root.end(); ++root_it){string key = root_it->first;if("TKT" == key){boost::property_tree::ptree tkt_node = root.get_child(key);boost::property_tree::ptree::iterator tkt_node_it = tkt_node.begin();for(; tkt_node_it != tkt_node.end(); ++tkt_node_it){boost::property_tree::ptree tkt = tkt_node_it->second;boost::property_tree::ptree::iterator tkt_it = tkt.begin();for(; tkt_it != tkt.end(); ++tkt_it){string tkt_key = tkt_it->first;if("CPN" == tkt_key){boost::property_tree::ptree cpn_node = tkt.get_child(tkt_key);boost::property_tree::ptree::iterator cpn_node_it = cpn_node.begin();for(; cpn_node_it != cpn_node.end(); ++cpn_node_it){boost::property_tree::ptree cpn = cpn_node_it->second;boost::property_tree::ptree::iterator cpn_it = cpn.begin();for(; cpn_it != cpn.end();++cpn_it){string cpn_key = cpn_it->first;string cpn_val = cpn.get<string>(cpn_key);cout<<cpn_key<<":"<<cpn_val<<endl;}}}else{string tkt_val = tkt.get<string>(tkt_key);cout << tkt_key << ":"<<tkt_val<<endl;}}}}else{string val = root.get<string>(key);cout << key <<":"<< val <<endl;//Sleep(1000);}}
}void bianli_json(void)
{string json_string="{\"-f\": \"/usr/reservedfff_dir\", \"-s\": \"/usr/reservedddd_dir\"}";string str_head;string str_node_val;boost::property_tree::ptree pt,p1,p2;stringstream stream(json_string);try{boost::property_tree::read_json<boost::property_tree::ptree>(stream, pt);cout<<"parsing ok\n"<<endl;for (boost::property_tree::ptree::iterator ita = pt.begin(); ita != pt.end(); ++ita){cout<<"first:"<<ita->first<<endl;str_node_val = pt.get<string>(ita->first);cout<<str_node_val<<endl;}}catch(std::runtime_error& e){std::cout<<e.what()<<endl;}
}void test(void)
{string str_json = "{\"TEST\":\"\",\"MSG\":\"130\",\"TKT\":[{\"DTYP\":\"T\",\"STOT\":\"1\",\"SNUM\":\"1\",\"CPN\":[{\"CNBR\":\"1\",\"DDAT\":\"090117\",\"DTME\":\"1205\",\"ADAT\":\"090117\",\"ATME\":\"1340\",\"ORIG\":\"TSA\",\"DEST\":\"PVG\",\"ALC1\":\"FM\",\"FLTN\":\"802\",\"CLAS\":\"Y\",\"FSTN\":\"OK\",\"FBAS\":\"Y\",\"BAGA\":\"20K\"}]}]}";std::stringstream str_stream(str_json);boost::property_tree::ptree root;boost::property_tree::read_json(str_stream,root);boost::property_tree::ptree tkt = root.get_child("TKT");stringstream tkt_stream;boost::property_tree::write_json(tkt_stream, tkt);cout<<tkt_stream.str()<<endl; //通过打印可以看到 first 为空for(boost::property_tree::ptree::iterator it = tkt.begin(); it!=tkt.end();++it){boost::property_tree::ptree inner = it->second; //first为空//string DTYP_val = inner.get<string>("DTYP");//cout << "DTYP" <<":"<< DTYP_val<<endl;boost::property_tree::ptree::iterator it_tkt = inner.begin();for(; it_tkt != inner.end(); ++it_tkt){string innet_key = it_tkt->first;cout<<innet_key<<":"<<inner.get<string>(innet_key)<<endl;}break;}//    boost::property_tree::ptree pt,pptt,ttt;//    string s = "{\"data\":[{\"id\":1,\"name\":\"chen\"},{\"id\":2,\"name\":\"zhang\"}]}";//    stringstream stream(s);//    read_json(stream, pt);//    pptt = pt.get_child("data");//    for (boost::property_tree::ptree::iterator it = pptt.begin(); it != pptt.end(); ++it)//    {//        ttt = it->second; //first为空//        cout<<"id="<<ttt.get<string>("id")<<endl;//        cout<<"name="<<ttt.get<string>("name")<<endl;//    }
}void parseMsg_1(void)
{string msg_str = "{\"MSG\":\"130\",\"CRSC\":\"MU\",\"CRSL\":\"BJS\",\"TAID\":\"08692057\",\"IHID\":\"PEK112\",\"ORGT\":\"A\",\"CRSN\":\"9995\",\"IHIB\":\"PEK112\",\"IDTP\":\"B\",\"PNR1\":\"NYFY37\",\"PNR2\":\"MU\",\"SURN\":\"zhang\",\"GIVN\":\"san\",\"FMID\":\"PPG19739941\",\"DTIS\":\"030117\",\"JORG\":\"TPE\",\"JDST\":\"MAD\",\"FAMT\":\"1560.00\",\"FCUR\":\"CNY\",\"TAMT\":\"1660.00\",\"TCUR\":\"CNY\",\"FANF\":\"H/1560.00/CNY+G/00:00/CNY\",\"FOPF\":\"CC\",\"TAXF\":\"T/CNY/50.00/CN+T/CNY/50.00/YQ\",\"FACF\":\"M/09JAN17TSA FM PVG MU JFK/-GRU JJ MAD1560.00CNY1560.00END\",\"TKT\":[{\"DTYP\":\"T\",\"STOT\":\"1\",\"SNUM\":\"1\",\"CPN\":[{\"CNBR\":\"1\",\"DDAT\":\"090117\",\"DTME\":\"1205\",\"ADAT\":\"090117\",\"ATME\":\"1340\",\"ORIG\":\"TSA\",\"DEST\":\"PVG\",\"ALC1\":\"FM\",\"FLTN\":\"802\",\"CLAS\":\"Y\",\"FSTN\":\"OK\",\"FBAS\":\"Y\",\"BAGA\":\"20K\"},{\"CNBR\":\"1\",\"DDAT\":\"090117\",\"DTME\":\"1205\",\"ADAT\":\"090117\",\"ATME\":\"1340\",\"ORIG\":\"TSA\",\"DEST\":\"PVG\",\"ALC1\":\"FM\",\"FLTN\":\"802\",\"CLAS\":\"Y\",\"FSTN\":\"OK\",\"FBAS\":\"Y\",\"BAGA\":\"20K\"}]},{\"DTYP\":\"T\",\"STOT\":\"1\",\"SNUM\":\"1\",\"CPN\":[{\"CNBR\":\"1\",\"DDAT\":\"090117\",\"DTME\":\"1205\",\"ADAT\":\"090117\",\"ATME\":\"1340\",\"ORIG\":\"TSA\",\"DEST\":\"PVG\",\"ALC1\":\"FM\",\"FLTN\":\"802\",\"CLAS\":\"Y\",\"FSTN\":\"OK\",\"FBAS\":\"Y\",\"BAGA\":\"20K\"}]}]}";stringstream msg_ss(msg_str);boost::property_tree::ptree msg;boost::property_tree::read_json(msg_ss, msg);boost::property_tree::ptree::iterator msg_it = msg.begin();for(; msg_it != msg.end(); ++msg_it){string msg_key = msg_it->first;string val = "";if("TKT" == msg_key){boost::property_tree::ptree tkt_node = msg.get_child(msg_key);boost::property_tree::ptree::iterator tkt_node_it = tkt_node.begin();for(; tkt_node_it != tkt_node.end(); ++tkt_node_it){boost::property_tree::ptree tkt = tkt_node_it->second;boost::property_tree::ptree::iterator tkt_it = tkt.begin();for(; tkt_it != tkt.end(); ++tkt_it){string tkt_key = tkt_it->first;if("CPN" == tkt_key){boost::property_tree::ptree cpn_node = tkt.get_child(tkt_key);boost::property_tree::ptree::iterator cpn_node_it = cpn_node.begin();for(; cpn_node_it != cpn_node.end(); ++cpn_node_it){boost::property_tree::ptree cpn = cpn_node_it->second;boost::property_tree::ptree::iterator cpn_it = cpn.begin();for(; cpn_it != cpn.end(); ++cpn_it){string cpn_key = cpn_it->first;val = cpn.get<string>(cpn_key);cout << cpn_key << ":" << val <<endl;}}}else{val = tkt.get<string>(tkt_key);cout<< tkt_key << ":" << val <<endl;}}}}else{val = msg.get<string>(msg_key);cout<< msg_key<<":"<<val<<endl;}}}void parseMsg(void)
{string msg_str = "{\"MSG\":\"MSG\",\"CRSC\":\"CRSC\",\"CRSL\":\"CRSL\",\"TAID\":\"TAID\",\"IHID\":\"IHID\",\"ORGT\":\"ORGT\",\"CRSN\":\"CRSN\",\"IHIB\":\"IHIB\",\"IDTP\":\"IDTP\",\"PNR1\":\"PNR1\",\"PNR2\":\"PNR2\",\"TIF\":[{\"SURN\":\"SURN\",\"GIVN\":\"GIVN\",\"FMID\":\"FMID\",\"INFP\":\"INFP\",\"UMCH\":\"UMCH\",\"JORG\":\"JORG\",\"JDST\":\"JDST\",\"FAMT\":\"FAMT\",\"FCUR\":\"FCUR\",\"TAMT\":\"TAMT\",\"TCUR\":\"TCUR\",\"FANF\":\"FANF\",\"FOPF\":\"FOPF\",\"TAXF\":\"TAXF\",\"TKT\":[{\"TKNB\":\"TKNB\",\"STOT\":\"STOT\",\"SNUM\":\"SNUM\",\"CPN\":[{\"CNBR\":\"CNBR\",\"DDAT\":\"DDAT\",\"DTME\":\"DTME\",\"ADAT\":\"ADAT\",\"ATME\":\"ATME\",\"ORIG\":\"ORIG\",\"DEST\":\"DEST\",\"ALC1\":\"ALC1\",\"FLTN\":\"FLTN\",\"CLAS\":\"CLAS\",\"FSTN\":\"FSTN\",\"FBAS\":\"FBAS\",\"BAGA\":\"BAGA\"},{\"CNBR\":\"CNBR\",\"DDAT\":\"DDAT\",\"DTME\":\"DTME\",\"ADAT\":\"ADAT\",\"ATME\":\"ATME\",\"ORIG\":\"ORIG\",\"DEST\":\"DEST\",\"ALC1\":\"ALC1\",\"FLTN\":\"FLTN\",\"CLAS\":\"CLAS\",\"FSTN\":\"FSTN\",\"FBAS\":\"FBAS\",\"BAGA\":\"BAGA\"}]},{\"TKNB\":\"TKNB\",\"STOT\":\"STOT\",\"SNUM\":\"SNUM\",\"CPN\":[{\"CNBR\":\"CNBR\",\"DDAT\":\"DDAT\",\"DTME\":\"DTME\",\"ADAT\":\"ADAT\",\"ATME\":\"ATME\",\"ORIG\":\"ORIG\",\"DEST\":\"DEST\",\"ALC1\":\"ALC1\",\"FLTN\":\"FLTN\",\"CLAS\":\"CLAS\",\"FSTN\":\"FSTN\",\"FBAS\":\"FBAS\",\"BAGA\":\"BAGA\"},{\"CNBR\":\"CNBR\",\"DDAT\":\"DDAT\",\"DTME\":\"DTME\",\"ADAT\":\"ADAT\",\"ATME\":\"ATME\",\"ORIG\":\"ORIG\",\"DEST\":\"DEST\",\"ALC1\":\"ALC1\",\"FLTN\":\"FLTN\",\"CLAS\":\"CLAS\",\"FSTN\":\"FSTN\",\"FBAS\":\"FBAS\",\"BAGA\":\"BAGA\"}]}]},{\"SURN\":\"SURN\",\"GIVN\":\"GIVN\",\"FMID\":\"FMID\",\"INFP\":\"INFP\",\"UMCH\":\"UMCH\",\"JORG\":\"JORG\",\"JDST\":\"JDST\",\"FAMT\":\"FAMT\",\"FCUR\":\"FCUR\",\"TAMT\":\"TAMT\",\"TCUR\":\"TCUR\",\"FANF\":\"FANF\",\"FOPF\":\"FOPF\",\"TAXF\":\"TAXF\",\"TKT\":[{\"TKNB\":\"TKNB\",\"STOT\":\"STOT\",\"SNUM\":\"SNUM\",\"CPN\":[{\"CNBR\":\"CNBR\",\"DDAT\":\"DDAT\",\"DTME\":\"DTME\",\"ADAT\":\"ADAT\",\"ATME\":\"ATME\",\"ORIG\":\"ORIG\",\"DEST\":\"DEST\",\"ALC1\":\"ALC1\",\"FLTN\":\"FLTN\",\"CLAS\":\"CLAS\",\"FSTN\":\"FSTN\",\"FBAS\":\"FBAS\",\"BAGA\":\"BAGA\"},{\"CNBR\":\"CNBR\",\"DDAT\":\"DDAT\",\"DTME\":\"DTME\",\"ADAT\":\"ADAT\",\"ATME\":\"ATME\",\"ORIG\":\"ORIG\",\"DEST\":\"DEST\",\"ALC1\":\"ALC1\",\"FLTN\":\"FLTN\",\"CLAS\":\"CLAS\",\"FSTN\":\"FSTN\",\"FBAS\":\"FBAS\",\"BAGA\":\"BAGA\"}]},{\"TKNB\":\"TKNB\",\"STOT\":\"STOT\",\"SNUM\":\"SNUM\",\"CPN\":[{\"CNBR\":\"CNBR\",\"DDAT\":\"DDAT\",\"DTME\":\"DTME\",\"ADAT\":\"ADAT\",\"ATME\":\"ATME\",\"ORIG\":\"ORIG\",\"DEST\":\"DEST\",\"ALC1\":\"ALC1\",\"FLTN\":\"FLTN\",\"CLAS\":\"CLAS\",\"FSTN\":\"FSTN\",\"FBAS\":\"FBAS\",\"BAGA\":\"BAGA\"},{\"CNBR\":\"CNBR\",\"DDAT\":\"DDAT\",\"DTME\":\"DTME\",\"ADAT\":\"ADAT\",\"ATME\":\"ATME\",\"ORIG\":\"ORIG\",\"DEST\":\"DEST\",\"ALC1\":\"ALC1\",\"FLTN\":\"FLTN\",\"CLAS\":\"CLAS\",\"FSTN\":\"FSTN\",\"FBAS\":\"FBAS\",\"BAGA\":\"BAGA\"}]}]}]}";stringstream msg_ss(msg_str);ptree msg;read_json(msg_ss, msg);string val = "";for(ptree::iterator msg_it = msg.begin(); msg_it != msg.end(); ++msg_it){string msg_key = msg_it->first;if("TIF" == msg_key){ptree tif_node = msg.get_child(msg_key);for(ptree::iterator tif_node_it = tif_node.begin(); tif_node_it != tif_node.end(); ++tif_node_it){ptree tif = tif_node_it->second;for(ptree::iterator tif_it = tif.begin(); tif_it != tif.end(); ++tif_it){string tif_key = tif_it->first;if("TKT" == tif_key){ptree tkt_node = tif.get_child(tif_key);for(ptree::iterator tkt_node_it = tkt_node.begin(); tkt_node_it != tkt_node.end(); ++tkt_node_it){ptree tkt = tkt_node_it->second;for(ptree::iterator tkt_it = tkt.begin(); tkt_it != tkt.end(); ++tkt_it){string tkt_key = tkt_it->first;if("CPN" == tkt_key){ptree cpn_node = tkt.get_child(tkt_key);for(ptree::iterator cpn_node_it = cpn_node.begin(); cpn_node_it != cpn_node.end(); ++cpn_node_it){ptree cpn = cpn_node_it->second;for(ptree::iterator cpn_it = cpn.begin(); cpn_it != cpn.end(); ++cpn_it){string cpn_key = cpn_it->first;val = cpn.get<string>(cpn_key);cout<< cpn_key <<":"<<val<<endl;}}}else{val = tkt.get<string>(tkt_key);cout<<tkt_key<<":"<<val<<endl;}}}}else{val = tif.get<string>(tif_key);cout<< tif_key << ":" <<val <<endl;}}}}else{val = msg.get<string>(msg_key);cout<< msg_key << ":" <<val<<endl;}}
}int main()
{//    write_json_data_into_file();//    system("pause");//    read_json_data_from_file();//    system("pause");//    write_json_data_into_string();//    system("pause");//    read_json_data_from_string();cout<<"---------------------------"<<endl;testMsg();cout<<"---------------------------"<<endl;bianli_json();cout<<"---------------------------"<<endl;test();cout<<"---------------------------"<<endl;parseMsg();return 0;
}



本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/496893.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

掌控谈话~标注对方的痛苦

为什么会谈话失败&#xff1f; 人与人之间的想法是不一样的。如果对方认为你和自己不是同类&#xff0c;不能体会到自己&#xff0c;在谈话的时候自然而然就建立了严密的防御战线&#xff0c;你没法直接攻进去。 想要主导谈话的你&#xff0c;必须得知道为什么对方会痛苦&…

oracle10g 监听服务无法启动

问题&#xff1a;在“运行”输入services.msc&#xff0c;启动服务OracleOraDb10g_homelTNSListener出现如下错误信息&#xff1a;“本地计算机上的OracleOraDb10g_homelTNSListener服务启动后又停止了。一些服务自动停止&#xff0c;如果它们没有什么可做的&#xff0c;例如“…

C++学习之路 | PTA乙级—— 1046 划拳 (15 分)(精简)

1046 划拳 (15 分) 划拳是古老中国酒文化的一个有趣的组成部分。酒桌上两人划拳的方法为&#xff1a;每人口中喊出一个数字&#xff0c;同时用手比划出一个数字。如果谁比划出的数字正好等于两人喊出的数字之和&#xff0c;谁就赢了&#xff0c;输家罚一杯酒。两人同赢或两人同…

盘点国内最具实力的双足仿人机器人研发团队有哪些?

来源&#xff1a;工业机器人之家北京理工大学 黄强教授团队北京理工大学借鉴人类长期进化所具备自然、快速、协调运动机理和灵巧结构特征&#xff0c;创新地研究了仿人机器人的仿生运动规划、控制与系统集成等关键技术&#xff0c;取得了新突破。提出了仿人机器人运动规划新方法…

转:SQL SERVER中一些常见性能问题的总结

1.对查询进行优化&#xff0c;应尽量避免全表扫描&#xff0c;首先应考虑在 where 及 order by 涉及的列上建立索引。 2.应尽量避免在 where 子句中对字段进行 null 值判断&#xff0c;否则将导致引擎放弃使用索引而进行全表扫描&#xff0c;如&#xff1a;select id from t wh…

C++学习之路 | PTA乙级—— 1047 编程团体赛 (20 分)(精简)

1047 编程团体赛 (20 分) 编程团体赛的规则为&#xff1a;每个参赛队由若干队员组成&#xff1b;所有队员独立比赛&#xff1b;参赛队的成绩为所有队员的成绩和&#xff1b;成绩最高的队获胜。 现给定所有队员的比赛成绩&#xff0c;请你编写程序找出冠军队。 输入格式&#xf…

掌控谈话~让对方说“不”

曾经有一句话很经典&#xff1a;勇敢说“No”&#xff01; 这句话的背景是&#xff0c;大多数人为了取悦他人&#xff0c;往往委曲求全&#xff0c;不敢说“不”。因此&#xff0c;说“不”需要更大的勇气和力量。再进一步&#xff0c;说“不”的人拥有更大的主导权&#xff0…

数据科学研究的现状与趋势

来源&#xff1a;数据科学DataScience大数据时代的到来催生了一门新的学科——数据科学。本文第1节探讨数据科学的内涵、发展简史、学科地位和知识体系等四个基本问题&#xff0c;并提出了数据科学的两个基本类型——专业数据科学和专业中的数据科学。第2节提出现阶段数据科学研…

DataGridView直接导出EXCEL

1.直接将DataGridView显示的内容导出Excel 1publicvoidDataToExcel(DataGridView m_DataView)2{ 3 SaveFileDialog kk new SaveFileDialog(); 4 kk.Title "保存EXECL文件"; 5 kk.Filter "EXECL文件(*.xls) |*.xls |所有文…

C++学习之路 | PTA乙级—— 1048 数字加密 (20 分)(精简)

1048 数字加密 (20 分) 本题要求实现一种数字加密方法。首先固定一个加密用正整数 A&#xff0c;对任一正整数 B&#xff0c;将其每 1 位数字与 A 的对应位置上的数字进行以下运算&#xff1a;对奇数位&#xff0c;对应位的数字相加后对 13 取余——这里用 J 代表 10、Q 代表 1…

掌控谈话~让对方说“你说得对

一个好的谈话结果是要让对方认可自己的想法。 1.有效的停顿&#xff1a;沉默的力量是强大的。我告诉班吉&#xff08;谈判专家&#xff09;在强调的时候使用停顿&#xff0c;鼓励萨巴亚&#xff08;谈判对象&#xff09;保持对话直到最后&#xff0c;就像走出沼泽一样&#xff…

boost的字符串处理函数——format

来源&#xff1a;http://www.cnblogs.com/TianFang/archive/2013/02/04/2891501.html boost::format的格式一般为&#xff1a; boost::format( "format-string ") % arg1 % arg2 % ... % argN ; 注意这里没有示例对象&#xff0c;format-string代表需要格式…

GIS单词汇总

Projection: Transverse_Mercator 墨卡托投影 false_easting: -3457147.813600 东伪偏移 false_northing: 0.000000 北纬偏移 central_meridian: 121.464423 中央子午线 scale_factor: 1.000000 比例因子 latitude_of_origin: 0.000000…

掌控谈话~谈价格的秘诀

很多谈判的内容是&#xff0c;一方提价很高&#xff0c;不然就不合作&#xff1b;一方有钱但是没有那么多钱&#xff0c;希望能够以合理的价格达成合作。这时候的谈判就是一个谈价格的过程。 这时候&#xff0c;要点是&#xff0c; 1.设定自己的心理价格&#xff0c;最好精确…

C++学习之路 | PTA乙级—— 1049 数列的片段和 (20 分)(精简)

1049 数列的片段和 (20 分) 给定一个正数数列&#xff0c;我们可以从中截取任意的连续的几个数&#xff0c;称为片段。例如&#xff0c;给定数列 { 0.1, 0.2, 0.3, 0.4 }&#xff0c;我们有 (0.1) (0.1, 0.2) (0.1, 0.2, 0.3) (0.1, 0.2, 0.3, 0.4) (0.2) (0.2, 0.3) (0.2, 0.3…

Boost学习之正则表达式--regex

来源&#xff1a;http://blog.chinaunix.net/uid-21222282-id-1829265.html 来源&#xff1a;http://www.cnblogs.com/undermoon/archive/2009/11/30/1613508.html 来源&#xff1a;http://blog.csdn.net/guyulongcs/article/details/7838753 来源&#xff1a;http://blo…

(转载)做好一个系统分析师、项目经理75条准则(一)

(转载)做好一个系统分析师、项目经理75条准则(一) 1. 你们的项目组使用源代码管理工具了么&#xff1f; 应该用。VSS、CVS、PVCS、ClearCase、CCC/Harvest、FireFly都可以。我的选择是VSS。 2. 你们的项目组使用缺陷管理系统了么&#xff1f; 应该用。ClearQuest太复杂&#…

智能的源泉,大脑从何而来?

作者&#xff1a;谢平 中国科学院大学教授引言&#xff1a;人类的神奇常常归结于一个智慧的大脑以及贯穿于其中的无比复杂的神经网络&#xff0c;并认为这源自上帝之手&#xff0c;但其实它并不是无中生有的&#xff0c;而是自然演化的产物&#xff0c;虽然是一个无与伦比的杰作…

掌控谈话~校准问题

当谈判即将破裂&#xff0c;怎么办&#xff1f; 你想这样&#xff0c;对方想那样&#xff0c;最后对方直接想要放弃谈判&#xff0c;应该怎么做&#xff1f; 其实很简单&#xff1a;对方处于“不相信”的状态。他们不认为谈判能得到结果。并不是因为没得谈而放弃&#xff0c;…

C++学习之路 | PTA乙级—— 1050 螺旋矩阵 (25 分)(精简)

1050 螺旋矩阵 (25 分) 本题要求将给定的 N 个正整数按非递增的顺序&#xff0c;填入“螺旋矩阵”。所谓“螺旋矩阵”&#xff0c;是指从左上角第 1 个格子开始&#xff0c;按顺时针螺旋方向填充。要求矩阵的规模为 m 行 n 列&#xff0c;满足条件&#xff1a;mn 等于 N&#x…