Guest User

Untitled

a guest
Oct 21st, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.13 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication1
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             int input, input2;
  13.             while (true)
  14.             {
  15.                 Console.ForegroundColor = ConsoleColor.White;
  16.                 input = int.Parse(Console.ReadLine());
  17.                 //input2 = int.Parse(Console.ReadLine());
  18.  
  19.                 Console.ForegroundColor = ConsoleColor.Green;
  20.                 Console.WriteLine(arrangedDigits(input).ToString());
  21.                 //Console.ReadKey();
  22.             }
  23.         }
  24.  
  25.         public static int power(int a)
  26.         {
  27.             if (a == 1)
  28.                 return 1;
  29.             return power(a - 1) * a;
  30.         }
  31.  
  32.         public static int digitSum(int a)
  33.         {
  34.             if (a < 10)
  35.                 return 1;
  36.             return digitSum(a / 10) + 1;
  37.         }
  38.  
  39.         public static int devide(int a, int b)
  40.         {
  41.             if (a <= 0)
  42.                 return 0;
  43.             return devide(a - b, b) + 1;
  44.         }
  45.  
  46.         public static int digits(int n, int digit)
  47.         {
  48.             if (n == 0)
  49.                 return 0;
  50.             if (n % 10 == digit)
  51.                 return digits(n / 10, digit) + 1;
  52.             else
  53.                 return digits(n / 10, digit);
  54.         }
  55.  
  56.         public static int series(int n)
  57.         {
  58.             if (n <= 0)
  59.                 return 0;
  60.             return series(n - 2) + (n - 1) * 2 + n * 4;
  61.         }
  62.  
  63.         public static int maxDigit(int n)
  64.         {
  65.             if (n < 10)
  66.             {
  67.                 return n;
  68.             }
  69.             int nextDigit = maxDigit(n / 10);
  70.             if (nextDigit >= n % 10)
  71.                 return nextDigit;
  72.             return n % 10;
  73.         }
  74.  
  75.         public static bool arrangedDigits(int n)
  76.         {
  77.             if (n < 10)
  78.                 return true;
  79.             bool result = arrangedDigits(n / 10);
  80.  
  81.             if (n % 10 >= (n / 10) % 10 && result)
  82.                 return true;
  83.             return false;
  84.         }
  85.     }
  86. }
Add Comment
Please, Sign In to add comment