- 1
- 2
- 3
return ("" + ((10 - (acn = "229" + acn)
.Select((c, с) => (int)(c - '0') * (с % 2 + 1))
.Sum(c => c / 10 + c % 10) % 10) % 10)).Insert(0, acn);
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+142
return ("" + ((10 - (acn = "229" + acn)
.Select((c, с) => (int)(c - '0') * (с % 2 + 1))
.Sum(c => c / 10 + c % 10) % 10) % 10)).Insert(0, acn);
+145
public string define(string content)
{
int till;
char[] CharArr = content.ToCharArray();
for (int i = 0; i < CharArr.Length; i++)
{
if (CharArr[i] == 'i')
{
till = i;
}
}
string Re = content.Substring(0,till);
return Re;
}
С тостера. Я рыдал.
+145
protected virtual void OnDisconnected()
{
DispatcherHelper.CheckBeginInvokeOnUI(() =>
{
...
Cameras.ToList().Clear();
Meltings.ToList().Clear();
Spans.ToList().Clear();
...
});
}
Очищаем коллекции с данными, привязанные на списковые контролы UI. Доступ к свойствам Cameras, Meltings, Spans только через IEnumerable<>. Как же их очистить?
+144
public static class BoolExt
{
public static string ToYesNoString(this bool value)
{
return value ? "Да" : "Нет";
}
}
+143
public static bool IsEmpty(this string input)
{
return String.IsNullOrEmpty(input);
}
А почему бы и да?
+141
string log;
...
try
{
Logger.SaveLog(fullPath, log);
}
catch (Exception ex)
{
Logger.SaveLog(fullPath, ex.ToString());
}
Senior developer...
+142
public void AllocateMemory(ref int[] segmentSizeProcess)
{
int[] difference;
int j = 0;
int tempo = 0;
for (int i = 0; i < segmentSizeProcess.Count(); i++)
{
difference = new int[memory.Count]; // храним разность размера блока памяти и требуемого размера для процесса
for (int count = 0; count < memory.Count; count++)
{
difference[count] = -2; // предварительно инициализируем
}
for (int count_memory=0; count_memory<memory.Count();
count_memory++)
{
if (memory[count_memory].size - segmentSizeProcess[i] >= 0) // если равно 0, значит
// сегмент полностью распределён
{
if (!memory[count_memory].isAllocate)
{ difference[count_memory] = memory[count_memory].size - segmentSizeProcess[i]; }
else
{ difference[count_memory] = -1; } // если сегмент занят -
// то он недоступен
}
}
tempo = GetMinDifference(ref difference); // получаем индекс минимальной разности
// если результат "-", значит секторы заняты, выходим из цикла
if (difference[tempo] >= 0)
{
memory.ElementAt(tempo).isAllocate = true; // процесс занял сегмент
if (difference[tempo] > 0) // если остаётся фрагмент памяти
{
CreateDifferenceSegment(difference[tempo]); // создаем новый сегмент, равный
// наименьшей разности памяти сегмента и памяти для процесса
}
memory[tempo].size = segmentSizeProcess[i]; // распределяем память
}
else
{
break;
}
}
}
Примерная реализация алгоритма best-fit
+142
public class Generator
{
private Random R = new Random();
public Generator()
{
}
public int GetNumber(int left, int right)
{
return R.Next(left, right);
}
}
Полезный класс
+143
System.String origString;
System.Int32 index;
System.Console.WriteLine("Введите строку: ");
origString = System.Console.ReadLine();
System.Int32 length = 0;
for (int i = 0; i < origString.Length; i++)
length++;
System.Console.WriteLine("Какую букву вычесть?: ");
index = System.Console.Read() - 49;
System.Char[] newString = new System.Char[origString.Length];
for (int i = 0; i < length; i++)
{
if (i != index && index != i && i != null && index != null)
{
newString[i] = origString[i];
}
if (i == index && index == i && i != null && index != null)
{
newString[i] = Convert.ToChar(7);
}
}
System.Console.Write("Результат: ");
length = 0;
for (int i = 0; i < newString.Length; i++)
length++;
for(int i = 0; i < length; i++)
System.Console.Write(newString[i]);
System.Console.ReadLine();
System.Console.ReadLine();
Ответ на вопрос на toster.ru
Как сделать это на c#?
Вычеркните i-ю букву заданной строки
https://toster.ru/q/222727
+142
var leftDate = GetAll().Select(i => i.SaveDateTime).OrderBy(i => i).FirstOrDefault();
var rigthDate = GetAll().Select(i => i.SaveDateTime).OrderByDescending(i => i).FirstOrDefault();
// 1e7 - количество тактов в секунде (а в итоге: проверка разницы в неделю)
while (rigthDate.Ticks - leftDate.Ticks > 1e7 * 60 * 60 * 24 * 7)
{
....................................
}
с точностью до тика.