Advertisement
Guest User

c# kod za marka zoricu 3/17

a guest
Dec 5th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.89 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ZivkovicDj05122019_2
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int i, n, h, s, d, j;
  14.             Console.WriteLine("Unesite broj: ");
  15.             n = int.Parse(Console.ReadLine());
  16.             j = n % 10;
  17.             d = (n % 100) / 10;
  18.             s = (n % 1000) / 100;
  19.             h = n / 1000;
  20.             if ((h % 2) == 0)
  21.                 n = n % 1000;
  22.             if ((s % 2) == 0)
  23.                 n = (n / 1000 * 100 + n % 100);
  24.             if ((d % 2) == 0)
  25.                 n = (n / 100 * 10 + n % 10);
  26.             if ((j % 2) == 0)
  27.                 n = n / 10;
  28.             Console.WriteLine("Uneti broj {0}.", n);
  29.             Console.ReadLine();
  30.  
  31.         }
  32.     }
  33. }
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78. using System;
  79. using System.Collections.Generic;
  80. using System.Linq;
  81. using System.Text;
  82. using System.Threading.Tasks;
  83.  
  84. namespace ZivkovicDj05122019_3
  85. {
  86.     class Program
  87.     {
  88.         static void Main(string[] args)
  89.         {
  90.             int h1,h2,h3,m1,m2,m3,s1,s2,s3,prvi,poslednji,ch,cm,cs;
  91.             Console.WriteLine("Unesite vreme dolaska Marka (sati): ");
  92.             h1 = Int32.Parse(Console.ReadLine());
  93.             Console.WriteLine("Unesite vreme dolaska Marka (minuti): ");
  94.             m1 = Int32.Parse(Console.ReadLine());
  95.             Console.WriteLine("Unesite vreme dolaska Janka (sati): ");
  96.             h2 = Int32.Parse(Console.ReadLine());
  97.             Console.WriteLine("Unesite vreme dolaska Janka (minuti): ");
  98.             m2 = Int32.Parse(Console.ReadLine());
  99.             Console.WriteLine("Unesite vreme dolaska Petra (sati): ");
  100.             h3 = Int32.Parse(Console.ReadLine());
  101.             Console.WriteLine("Unesite vreme dolaska Petra (minuti): ");
  102.             m3 = Int32.Parse(Console.ReadLine());
  103.             s1 = h1 * 3600 + m1 * 60;
  104.             s2 = h2 * 3600 + m2 * 60;
  105.             s3 = h3 * 3600 + m3 * 60;
  106.             if (s1 < s2 && s1 < s3)
  107.             {
  108.                 prvi = s1;
  109.             }
  110.             else if (s2 < s1 && s2 < s3)
  111.             {
  112.                 prvi = s2;
  113.             }
  114.             else
  115.             {
  116.                 prvi = s3;
  117.             }
  118.             if (s1 > s2 && s1 > s3)
  119.             {
  120.                 poslednji = s1;
  121.             }
  122.             else if (s2 > s1 && s2 > s3)
  123.             {
  124.                 poslednji = s2;
  125.             }
  126.             else
  127.             {
  128.                 poslednji = s3;
  129.             }
  130.  
  131.             cs = poslednji - prvi;
  132.             ch = cs / 3600;
  133.             cs -= ch * 3600;
  134.             cm = cs / 60;
  135.             Console.WriteLine("Prvi koji je dosao je cekao {0} sati i {1} minuta.", ch, cm);
  136.             Console.ReadLine();
  137.         }
  138.     }
  139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement