Advertisement
Guest User

Untitled

a guest
Sep 24th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6.  
  7.     class Program
  8.     {
  9.         static void Main()
  10.         {
  11.         string input;
  12.         int number;
  13.         input = Console.ReadLine();
  14.         if (!int.TryParse(input, out number) || number < 1000 || number > 9999)
  15.         {
  16.             Console.WriteLine("wrong");
  17.         }
  18.         else {
  19.             int digit_1 = number / 1000;
  20.             int digit_2 = (number / 100) % 10;
  21.             int digit_3 = (number % 100) / 10;
  22.             int digit_4 = number % 10;
  23.             int result = (10 * digit_1 + digit_2) - (10 * digit_4 + digit_3) + 1;
  24.             Console.WriteLine(result);
  25.         }
  26.     }
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement