Advertisement
abasar

vars actions

Dec 2nd, 2015
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.76 KB | None | 0 0
  1. //#3
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6.  
  7. namespace ConsoleApplication1210
  8. {
  9.     class Program
  10.     {
  11.         static bool Quick(int num)
  12.         {
  13.             if (num / 10 == 0)
  14.                 return false;
  15.             while (num / 10 != 0)
  16.             {
  17.                 int ahadot = num % 10;
  18.                 num /= 10;
  19.                 if (num % 10 <= ahadot)
  20.                     return false;
  21.             }
  22.             return true;
  23.         }
  24.  
  25.         static void Main(string[] args)
  26.         {
  27.             int num;
  28.             num = int.Parse(Console.ReadLine());
  29.             while (num != 999)
  30.             {
  31.                 Console.WriteLine(Quick(num));
  32.                 num = int.Parse(Console.ReadLine());
  33.             }
  34.         }
  35.     }
  36. }
  37.  
  38. //#4
  39. using System;
  40. using System.Collections.Generic;
  41. using System.Linq;
  42. using System.Text;
  43.  
  44. namespace ConsoleApplication1210
  45. {
  46.     class Program
  47.     {
  48.         static int Golem(int num, int digit)
  49.         {
  50.             int digits = 1, rep = num, i;
  51.             while (rep / 10 != 0)
  52.             {
  53.                 digits++;
  54.                 rep /= 10;
  55.             }
  56.             if (digit > digits)
  57.                 return -1;
  58.             for (i = 0; i < digit - 1; i++)
  59.             {
  60.                 num /= 10;
  61.             }
  62.             return num % 10;
  63.         }
  64.  
  65.         static void Main(string[] args)
  66.         {
  67.             int digit, num;
  68.             digit = int.Parse(Console.ReadLine());
  69.             num = int.Parse(Console.ReadLine());
  70.             while (num != 0)
  71.             {
  72.                 Console.WriteLine(Golem(num, digit));
  73.                 num = int.Parse(Console.ReadLine());
  74.             }
  75.         }
  76.     }
  77. }
  78.  
  79. //#5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement