Advertisement
Guest User

Untitled

a guest
Nov 21st, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int num = 0;
  6. int f = 0;
  7. int b = 0;
  8. int c = 0;
  9. int r = 0;
  10.  
  11. int main() {
  12. setlocale(LC_ALL, "ru");
  13.  
  14. cout << "Введите число "<< endl;
  15. cin >> num;
  16. /*if (99 < num && num < 999)
  17. {
  18. f = num % 10;
  19. b = (num / 10) % 10;
  20. c = num / 100;
  21. c = c * 4;
  22. b = b * 2;
  23. f = f * 1;
  24. cout << f + b + c << endl;
  25. }*/
  26. if (999 <= num <= 9999) { //для четырехзначных
  27. f = num % 100;
  28. b = (num / 10) % 10;
  29. c = (num / 100) % 10;
  30. r = num / 1000;
  31. c = c * 6;
  32. b = b * 4;
  33. f = f * 2;
  34. r = r * 1;
  35. cout << f + b + c + r << endl;
  36. }
  37.  
  38.  
  39. system("pause");
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement