Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- const int SIZE = 10;
- int main() {
- int arr[SIZE];
- for (int i = 0; SIZE > i; i++) {
- cout << "Enter " << i << " number: ";
- cin >> arr[i];
- }
- int serSum;
- cout << "Enter search sum: ";
- cin >> serSum;
- cout << "Result:";
- for (int i = 0; SIZE > i; i++) {
- int num = arr[i];
- int curSum = 0;
- while(num != 0) {
- curSum += num % 10;
- num /= 10;
- }
- if (curSum == serSum) {
- cout << " " << arr[i];
- }
- }
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement