Răspuns:
#include <iostream>
#include <vector>
int main()
{
int N;
std::cout << "N : ";
std::cin >> N;
std::vector<int> h;
std::cout << std::endl;
for(int j = 0; j<N;++j){
int x;
std::cin >> x;
h.push_back(x);
}
h.shrink_to_fit();
int rezultat = 0;
for(int y = 0; y < h.size(); ++y){
int x = h[y];
int s = 0;
while (x != 0) {
s = s + x % 10;
x = x / 10;
}
if(s == (y+1)) rezultat++;
}
std::cout << std::endl << rezultat;
return 0;
}