#include <iostream>
#include <vector>
#include <clocale>
int func(int& x)
{
int result = 0;
while (x > 0)
result += x % 10;
x /= 10;
}
return result;
int main()
std::setlocale(LC_ALL, "Russian");
int size;
std::cin >> size;
std::vector<int> vec(size);
for (int i = 0; i < size; i++)
std::cin >> vec[i];
for(auto& i : vec)
std::cout << func(i) << std::endl;
std::system("PAUSE >> void");
return 0;
#include <iostream>
#include <vector>
#include <clocale>
int func(int& x)
{
int result = 0;
while (x > 0)
{
result += x % 10;
x /= 10;
}
return result;
}
int main()
{
std::setlocale(LC_ALL, "Russian");
int size;
std::cin >> size;
std::vector<int> vec(size);
for (int i = 0; i < size; i++)
std::cin >> vec[i];
for(auto& i : vec)
std::cout << func(i) << std::endl;
std::system("PAUSE >> void");
return 0;
}