Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void numere(int n, int v[], int& suma)
- {
- suma = 0;
- for (int i = 0; i < n; i++)
- {
- int c = v[i], s = 0;
- while (c > 9)
- {
- s += c % 10;
- c /= 10;
- }
- if (c == s)
- suma += v[i];
- }
- if (!suma)
- suma = -1;
- }
- int main()
- {
- int suma, n = 5, v[] = {125,624,44,2110,23};
- numere(n, v, suma);
- cout << suma;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement