«Крв ние вода» — это сербская идиома, которая на английском языке переводится как «Кровь гуще воды». Эта идиома используется для выражения идеи о том, что семейные узы и отношения сильнее и важнее любых других связей или отношений.
В этой статье блога мы рассмотрим несколько методов и примеров кода, иллюстрирующих концепцию семейных уз и значение «krv nije voda» в различных языках программирования. Давайте погрузимся!
-
Python:
# Example 1: Checking if two people are family members def is_family_member(person1, person2): # Compare family relations based on shared last name last_name1 = person1.split()[-1] last_name2 = person2.split()[-1] return last_name1 == last_name2 # Example usage person1 = "John Smith" person2 = "Mary Smith" if is_family_member(person1, person2): print(f"{person1} and {person2} are family members!") else: print(f"{person1} and {person2} are not family members.") -
JavaScript:
// Example 2: Comparing family relations function areFamilyMembers(person1, person2) { // Extract last names const lastName1 = person1.split(' ').pop(); const lastName2 = person2.split(' ').pop(); return lastName1 === lastName2; } // Example usage const person1 = "John Smith"; const person2 = "Mary Smith"; if (areFamilyMembers(person1, person2)) { console.log(`${person1} and ${person2} are family members!`); } else { console.log(`${person1} and ${person2} are not family members.`); } -
Java:
// Example 3: Checking family relationship public class FamilyUtils { public static boolean areFamilyMembers(String person1, String person2) { // Extract last names String[] nameParts1 = person1.split(" "); String[] nameParts2 = person2.split(" "); String lastName1 = nameParts1[nameParts1.length - 1]; String lastName2 = nameParts2[nameParts2.length - 1]; return lastName1.equals(lastName2); } // Example usage public static void main(String[] args) { String person1 = "John Smith"; String person2 = "Mary Smith"; if (areFamilyMembers(person1, person2)) { System.out.println(person1 + " and " + person2 + " are family members!"); } else { System.out.println(person1 + " and " + person2 + " are not family members."); } } }
Эти примеры кода демонстрируют различные способы сравнения семейных отношений на основе фамилий. Используя идиому «krv nije voda» в качестве вдохновения, эти примеры подчеркивают важность семейных уз и значение общих родословных.