1110安装tdmgcc stoi

#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
struct Node{
	int rchild,lchild;
	int flag;
}node[128];
bool isroot[128] = {false};
int n,num = 0,root,maxn = -1,ans; 
void pre(int v,int index)
{
	if(v == -1) return;
	if(index > maxn) 
	{
		maxn = index;
		ans = v;
	}
	if(node[v].lchild != -1) pre(node[v].lchild,2 * index);
	if(node[v].rchild != -1) pre(node[v].rchild,2 * index + 1);
}
int main()
{
	string c;
	scanf("%d",&n);
	
	for(int i = 0; i < n; i++)
	{   getchar();
		cin>>c;
		if(c == "-") node[i].lchild = -1; 
		else {
			node[i].lchild = stoi(c);
			isroot[stoi(c)] = true;
		}
		getchar();
		cin>>c;
		if(c == "-") node[i].rchild = -1; 
		else {
			node[i].rchild = stoi(c); 
			isroot[stoi(c)] = true;
		}
	}
	for(int i = 0; i < n; i++)
        if(isroot[i] == false){
        	root = i;
        	break;
        }
	pre(root,1);
	if(maxn == n) printf("YES %d\n",ans);
	else printf("NO %d",root);
	system("pause");
	return 0;
} 

不知道有没有小伙伴和我一样 加上了c++11还是用不了stoi 

因为tdmgcc的版本太低了  我下了一个5.1.0的版本再加上c++11就可以用啦

困扰了好几天唯一的不足就是 安装在了c盘TAT

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值