diff --git a/python/src/module2/1.py b/python/src/module2/1.py new file mode 100644 index 0000000..1c0ae46 --- /dev/null +++ b/python/src/module2/1.py @@ -0,0 +1,12 @@ +n = int(input()) +arr = list(map(int, input().split())) +swaps = 0 +for i in range(n-1): + for j in range(0, n-i-1): + if arr[j] > arr[j+1]: + arr[j], arr[j+1] = arr[j+1], arr[j] + swaps += 1 + print(" ".join(map(str, arr))) + if swaps == 0: + print(0) + break \ No newline at end of file diff --git a/python/src/module2/2.py b/python/src/module2/2.py new file mode 100644 index 0000000..d4132dd --- /dev/null +++ b/python/src/module2/2.py @@ -0,0 +1,16 @@ +n = int(input()) +all_elems = [] +for i in range(n): + nums = list(map(int, input().split())) + all_elems.append(nums) + +for i in range(n-1): + for j in range(n-1-i): + if all_elems[j][1] < all_elems[j+1][1]: + all_elems[j] , all_elems[j+1] = all_elems[j+1], all_elems[j] + if all_elems[j][1] == all_elems[j+1][1]: + if all_elems[j][0] > all_elems[j+1][0]: + all_elems[j] , all_elems[j+1] = all_elems[j+1], all_elems[j] + +for i in range(n): + print(*all_elems[i]) \ No newline at end of file diff --git a/python/src/module2/5.py b/python/src/module2/5.py new file mode 100644 index 0000000..ce1116c --- /dev/null +++ b/python/src/module2/5.py @@ -0,0 +1,3 @@ +n = int(input()) +nums = set(map(int, input().split())) +print(len(nums)) \ No newline at end of file