100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > python翻译成c语言_将python字典翻译成C语言

python翻译成c语言_将python字典翻译成C语言

时间:2020-09-28 14:02:38

相关推荐

python翻译成c语言_将python字典翻译成C语言

字典将是c中的std :: map,具有两个元素的元组将是std :: pair。

提供的python代码将转换为:

#include

#include

typedef std::map<:pair int>, int> Dict;

typedef Dict::const_iterator It;

int main()

{

Dict d;

d[std::make_pair(0, 0)] = 0;

d[std::make_pair(1, 2)] = 1;

d[std::make_pair(2, 1)] = 2;

d[std::make_pair(2, 3)] = 3;

d[std::make_pair(3, 2)] = 4;

for (It it(d.begin()); it != d.end(); ++it)

{

int i(it->first.first);

int j(it->first.second);

std::cout <second <

<

}

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。