Thea The Photographer
Имах проблем с това на изпита и бих искал някой да ми каже защо вариант 1 е по-добър от вариант 2 ( и двата работят ):
Вариант 1:
int pictures = int.Parse(Console.ReadLine());
int filterTime = int.Parse(Console.ReadLine());
int filterFactor = int.Parse(Console.ReadLine());
int uploadTime = int.Parse(Console.ReadLine());
long overallFilterTime = (long)pictures * filterTime;
long filteredPictures = (long)Math.Ceiling((double)pictures * filterFactor/100);
long overallUploadTime = filteredPictures * uploadTime;
long time = overallUploadTime + overallFilterTime;
TimeSpan A = TimeSpan.FromSeconds(time);
Console.WriteLine("{0:D1}:{1:D2}:{2:D2}:{3:D2}",A.Days, A.Hours, A.Minutes, A.Seconds);
Вариант 2:
var pictures = int.Parse(Console.ReadLine());
var filterTime = int.Parse(Console.ReadLine());
var filterFactor = int.Parse(Console.ReadLine());
var uploadTime = int.Parse(Console.ReadLine());
var overallFilterTime = (long)pictures * filterTime;
var filteredPictures = (long)Math.Ceiling((double)pictures * filterFactor/100);
var overallUploadTime = filteredPictures * uploadTime;
var time = overallUploadTime + overallFilterTime;
TimeSpan A = TimeSpan.FromSeconds(time);
Console.WriteLine("{0:D1}:{1:D2}:{2:D2}:{3:D2}",A.Days, A.Hours, A.Minutes, A.Seconds);
Благодаря предварително!