SELECT user2.*,
SQRT(POW(69.1 * (user1.latitude::float - user2.latitude::float), 2) +
POW(69.1 * (user2.longtitude::float - user1.longitude::float) * COS(user1.latitude::float / 57.3), 2)
) distanse
FROM users user1, users user2
WHERE user1.user_id=@p_user_id
ORDER BY distanse
LIMIT 10
SELECT users.*,
SQRT(POW(69.1 * (@p_user_latitude::float - users.latitude::float), 2) +
POW(69.1 * (users.longtitude::float - @p_user_longitude::float) * COS(@p_user_latitude::float / 57.3), 2)
) distanse
FROM users
ORDER BY distanse
LIMIT 10
def dict_get_recursive(source, path):
current_dict = source
for path_idx, path_key in enumerate(path):
if path_idx == len(path)-1:
return current_dict.get(path_key, None)
current_dict = current_dict.get(path_key, None)
if current_dict is None:
return None
new_dic['Name_1'] = dict_get_recursive(source_1,['key_1','key_2','key_3'])
new_dic['Name_2'] = dict_get_recursive(source_2,['key_1','key_2'])
new_dic['Name_3'] = dict_get_recursive(source_1,['key_1','key_2','key_3','key_4'])
&НаСервере
Функция ПолучитьСтруктуруХраненияБазыДанныхНаСервере()
СтруктураБД = ПолучитьСтруктуруХраненияБазыДанных();
Для каждого СтрокаТаблицы Из СтруктураБД Цикл
Сообщить(СтрокаТаблицы.ИмяТаблицы + " = " + СтрокаТаблицы.ИмяТаблицыХранения);
Для каждого СтрокаПоля Из СтрокаТаблицы.Поля Цикл
Сообщить(" "+СтрокаПоля.ИмяПоля + " = " + СтрокаПоля.ИмяПоляХранения);
КонецЦикла;
КонецЦикла;
КонецФункции
current.Data = value;
numbers[i] % 2
заменить на i % 2
public static bool CheckWords(string text)
{
List<string[]> lines = new List<string[]>();
string[] arr_lines = text.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries );
foreach (string line in arr_lines)
{
string[] arr_words = line.Split(' ');
lines.Add(arr_words);
}
for (int current_line_num = 0; current_line_num < lines.Count - 1; current_line_num++)
{
for (int current_word_num = 0; current_word_num < lines[current_line_num].Length; current_word_num++)
{
if (current_word_num < lines[current_line_num + 1].Length
&& lines[current_line_num][current_word_num] == lines[current_line_num + 1][current_word_num])
{
return true; // совпадение!
}
}
}
return false;
}
public static void TestTexts()
{
string text =
@"This sentence is pretty long and
this sentence is also a test";
bool res = CheckWords(text);
string text2 =
@"This sentence also shouldn't
match as this has no words
below";
bool res2 = CheckWords(text2);
}