单选题

上述程序的输入为:

发布于 2022-03-03 14:07:47

#include<bits/stdc++.h>
using namespace std
vector<int>g[10]
int ans = 0
void dfs(int x){
if(g[x].size() == 0){
ans++
return
}
for(int i = 0 i < g[x].size() ++i){
dfs(g[x][i])
}
}
int main(){
int n, x
scanf("%d", &n)
for(int i = 2 i <= n ++i){
scanf("%d", &x)
g[x].push_back(i)
}
dfs(1)
cout<<ans<<endl
return 0
}
上述程序的输入为:
9
1 2 2 1 5 6 6 6
则输出为( )

登录后免费查看答案
关注者
0
被浏览
4
知识点
面圈网VIP题库

面圈网VIP题库全新上线,海量真题题库资源。 90大类考试,超10万份考试真题开放下载啦

去下载看看