SHARE
TWEET

fdgg

a guest Nov 19th, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     setlocale(NULL, "");
  7.     int n, s, l = 0, i, m, k;
  8.     s = 0;
  9.     cout << "Введите число" << "\n";
  10.     cin >> n;
  11.     m = n;
  12.     while (m > 0) {
  13.         k = m % 10;
  14.         ++l;
  15.         m /= 10;
  16.     }
  17.     while (l > 1) {
  18.         i = n / (10 * l);
  19.         if (l % 2 == 0) s += i;
  20.         else s -= i;
  21.         --l;
  22.         n = n % (10 * l);
  23.     }
  24.     cout << "Знакочередующаяся сумма цифр числа равна " << s;
  25.     system("pause");
  26.     return 0;
  27. }
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