Advertisement
ice_tea

Untitled

Sep 6th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.07 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 ConsoleApp2
  8. {
  9.     class time_format
  10.     {
  11.         public string format(string s, long k)
  12.         {
  13.             if ((k >= 10) && (k <= 19))
  14.             {
  15.                 if (s == "час") return "часов";
  16.                 else if (s == "минута") return "минут";
  17.                 else return "секунд";
  18.             }
  19.             if (k % 10 == 1) return s;
  20.             else if ((k % 10 >= 2) && (k % 10 <= 4))
  21.             {
  22.                 if (s == "час") return "часа";
  23.                 else
  24.                 {
  25.                     if (s == "минута") return "минуты";
  26.                     else return "секунды";
  27.                 }
  28.             }
  29.             else
  30.             {
  31.                 if (s == "час") return "часов";
  32.                 else if (s == "минута") return "минут";
  33.                 else return "секунд";
  34.             }
  35.         }
  36.     }
  37.     class Program
  38.     {
  39.         static void Main(string[] args)
  40.         {
  41.             long Time;
  42.             long hours, minuts, seconds;
  43.             Console.WriteLine("введите число");
  44.             Time = int.Parse(Console.ReadLine());
  45.             Console.Clear();
  46.             Console.Write("Осталось ");
  47.             hours = Time / 3600;
  48.             Console.Write(hours);
  49.             time_format t = new time_format();
  50.             Console.Write(" " + t.format("час", hours) + " ");
  51.             minuts = (Time) % 3600 / 60;
  52.             Console.Write(minuts);
  53.             Console.Write(" " + t.format("минута", minuts) + " ");
  54.             seconds = (Time) % 60;
  55.             Console.Write(seconds);
  56.             Console.Write(" " + t.format("секунда", seconds) + " ");
  57.             DateTime Date = DateTime.Now;
  58.             long cur_time = Time;
  59.             while (true)
  60.             {
  61.                 DateTime Date1 = DateTime.Now;
  62.                 long dif_time = Date1.Hour * 60 * 60 + Date1.Minute * 60 + Date1.Second - Date.Hour * 60 * 60 - Date.Minute * 60 - Date.Second;
  63.                 if (dif_time >= Time) break;
  64.                 if (Time - dif_time != cur_time)
  65.                 {
  66.                     Console.Clear();
  67.                     Console.Write("Осталось ");
  68.                     hours = (Time - dif_time) / 3600;
  69.                     Console.Write(hours);
  70.                     Console.Write(" " + t.format("час", hours) + " ");
  71.                     minuts = (Time - dif_time) % 3600 / 60;
  72.                     Console.Write(minuts);
  73.                     Console.Write(" " + t.format("минута", minuts) + " ");
  74.                     seconds = (Time - dif_time) % 60;
  75.                     Console.Write(seconds);
  76.                     Console.Write(" " + t.format("секунда", seconds) + " ");
  77.                     cur_time = Time - dif_time;
  78.                 }
  79.             }
  80.             Console.Clear();
  81.             Console.WriteLine("КОНЕЦ");
  82.         }
  83.     }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement