Advertisement
semenrbt

1laba

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