#include <iostream>
#include <vector>
using namespace std;
int main() {
int n;
vector<int> arr(n);
int a, b, c = 0;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> arr[n];
}
for (int i = 0; i < n; i++) {
if (arr[i] != -1) {
a = i;
while (arr[a] != -1) {
for (int j = 0; j < n; j++) {
if (a == arr[j]) {
b = arr[a];
arr[a] = -1;
a = b;
}
}
}
c++;
} else {
continue;
}
}
cout << c << endl;
return 0;
}
幫你tag你要找的電神 @臨末之頌
幫你tag你要找的電神 @臨末之頌
for (int i = 0; i < n; i++) {
cin >> arr[n];
}
這句啥意思...