Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. // Лаба 2 здача 3
  2. // Используя оператор do..while: угадать число от 1 до 1000 не более чем за 10 попыток (вводится предполагаемое число, программа "отвечает": искомое больше/меньше или отгадано)
  3.  
  4. #include <bits/stdc++.h>
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9. int x;
  10. cin >> x;
  11. int sum = 0;
  12. int ind = 1;
  13. while (x > 0) {
  14. if (ind % 2 == 0) sum += x % 10;
  15. x /= 10;
  16. ind++;
  17. }
  18. cout << sum;
  19. return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement