Advertisement
Weewee21

FunctionNumberInOrder

Dec 30th, 2020
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp25
  4. {
  5.     class Program
  6.     {
  7.         public static string SortedNumber(int num)
  8.         {
  9.             int minimum = num % 10;
  10.             num /= 10;
  11.             while (num > 0)
  12.             {
  13.                 if (num % 10 < minimum)
  14.                 {
  15.                     minimum = num % 10;
  16.                     num /= 10;
  17.                 }
  18.                 else
  19.                 {
  20.                     return "False";
  21.                 }
  22.             }
  23.             return "True";
  24.         }
  25.  
  26.         static void Main(string[] args)
  27.         {
  28.             string result;
  29.             int num;
  30.  
  31.             Console.WriteLine("Number: ");
  32.             num = int.Parse(Console.ReadLine());
  33.  
  34.             result = SortedNumber(num);
  35.             Console.WriteLine(result);
  36.         }
  37.     }
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement