SHARE
TWEET

nadezhda

daniil_mironoff Nov 3rd, 2019 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. const int SIZE = 10;
  6.  
  7.  
  8. int main() {
  9.     int arr[SIZE];
  10.     for (int i = 0; SIZE > i; i++) {
  11.         cout << "Enter " << i << " number: ";
  12.         cin >> arr[i];
  13.     }
  14.  
  15.     int serSum;
  16.     cout << "Enter search sum: ";
  17.     cin >> serSum;
  18.  
  19.     cout << "Result:";
  20.  
  21.     for (int i = 0; SIZE > i; i++) {
  22.         int num = arr[i];
  23.         int curSum = 0;
  24.  
  25.         while(num != 0) {
  26.             curSum += num % 10;
  27.             num /= 10;
  28.         }
  29.  
  30.         if (curSum == serSum) {
  31.             cout << " " << arr[i];
  32.         }
  33.  
  34.     }
  35.  
  36.    
  37.  
  38.     cout << endl;
  39.  
  40.     return 0;
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top