Advertisement
semenrbt

Kristina_1.3.1

Feb 4th, 2020
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.70 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main() {
  5.     int N = 0;
  6.     if(scanf("%d", &N) != 1) // Это ввод числа N с клавиатуры и проверка на то, введено-ли было число верно
  7.     {                       // Если было успешно введено одно число, то программа продолжает работу, иначе Ошибка и выход из программы
  8.         printf("Error.\n");
  9.         return 0;
  10.     }
  11.     if(N < 0) // По условию число натуральное
  12.     {
  13.         printf("Error.\n");
  14.         return 0;
  15.     }
  16.     int V = N%10;
  17.     N = N/10;
  18.     while(N > 0)
  19.     {
  20.         V = V*10 + N%10;
  21.         N = N/10;
  22.     }
  23.    
  24.     printf("V = %d\n", V);
  25.    
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement