Advertisement
VladoG

GPS-1_99km-Distance_1_2023_01_31

Feb 4th, 2023 (edited)
860
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.76 KB | Software | 0 0
  1.             int distance = 0;
  2.             int single = 0;
  3.             int dec = 0;
  4.             string text = "";
  5.             string sEnd = " и ";
  6.  
  7.  
  8.             Console.Write("Въведете разстояние в км: ");
  9.             distance = int.Parse(Console.ReadLine());
  10.  
  11.             dec = distance / 10;
  12.             single = distance - (dec * 10);
  13.  
  14.             if (dec != 0)
  15.             {
  16.                 if (dec == 1)
  17.                 {
  18.                     switch (distance)
  19.                     {
  20.                         case 10: text = text + "десет";
  21.                             break;
  22.                         case 11: text = text + "единадесет";
  23.                             break;
  24.                         case 12:
  25.                             text = text + "дванадесет";
  26.                             break;
  27.                         case 13:
  28.                             text = text + "тринадесет";
  29.                             break;
  30.                         case 14:
  31.                             text = text + "четиринадесет";
  32.                             break;
  33.                         case 15:
  34.                             text = text + "петнадесет";
  35.                             break;
  36.                         case 16:
  37.                             text = text + "шестнадесет";
  38.                             break;
  39.                         case 17:
  40.                             text = text + "седемнадесет";
  41.                             break;
  42.                         case 18:
  43.                             text = text + "осемнадесет";
  44.                             break;
  45.                         case 19:
  46.                             text = text + "деветнадесет";
  47.                             break;
  48.                         default:
  49.                             break;
  50.                     }
  51.                 }
  52.                 else
  53.                 {
  54.                     switch (dec)
  55.                     {
  56.                         case 2: text = text + "двадесет";
  57.                             break;
  58.                         case 3: text = text + "тридесет";
  59.                             break;
  60.                         case 4:
  61.                             text = text + "четирдесет";
  62.                             break;
  63.                         case 5:
  64.                             text = text + "петдесет";
  65.                             break;
  66.                         case 6:
  67.                             text = text + "шестдесет";
  68.                             break;
  69.                         case 7:
  70.                             text = text + "седемдесет";
  71.                             break;
  72.                         case 8:
  73.                             text = text + "осемдесет";
  74.                             break;
  75.                         case 9:
  76.                             text = text + "деветдесет";
  77.                             break;
  78.  
  79.                         default:
  80.                             break;
  81.                     }
  82.                 }
  83.             }
  84.            
  85.  
  86.             if (distance < 10 || distance > 20)
  87.             {
  88.  
  89.                if (distance > 20 && single != 0)
  90.                 {
  91.                     text = text + sEnd;
  92.                 }
  93.  
  94.                 switch (single)
  95.                         {
  96.                             case 1:
  97.                                 text = text + "един";
  98.                                 break;
  99.                             case 2:
  100.                                 text = text + "два";
  101.                                 break;
  102.                             case 3:
  103.                                 text = text + "три";
  104.                                 break;
  105.                             case 4:
  106.                                 text = text + "четири";
  107.                                 break;
  108.                             case 5:
  109.                                 text = text + "пет";
  110.                                 break;
  111.                             case 6:
  112.                                 text = text + "шест";
  113.                                 break;
  114.                             case 7:
  115.                                 text = text + "седем";
  116.                                 break;
  117.                             case 8:
  118.                                 text = text + "осем";
  119.                                 break;
  120.                             case 9:
  121.                                 text = text + "девет";
  122.                                 break;
  123.  
  124.                             default:
  125.                                 break;
  126.                         }
  127.             }
  128.            
  129.  
  130.             Console.WriteLine(text + " км");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement