Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
109166 胡海峰老师 19按规则查找数组中的数据 C++ Accepted 1 MS 276 KB 329 2025-02-05 15:27:47

Tests(10/10):


Code:

#include <iostream> using namespace std; int a[1005]={}; int main () { int n,m; cin>>n>>m; for(int i=1;i<=n;i++) cin>>a[i]; int t=1; cout<<a[t]<<" "; for(int j=2;j<=m;j++) { t = a[t]; cout<<a[t]<<" "; } return 0; } /* Input 5 2 5 2 3 1 4 5 4 5 2 3 1 4 Output 5 4 */