سؤال المسابقة:
https://www.codewars.com/kata/521c2db8ddc89b9b7a0000c1/train/python
الحل:
def snail(array):
ret = []
if array and array[0]:
size = len(array)
for n in xrange((size + 1) // 2):
for x in xrange(n, size - n):
ret.append(array[n][x])
for y in xrange(1 + n, size - n):
ret.append(array[y][-1 - n])
for x in xrange(2 + n, size - n + 1):
ret.append(array[-1 - n][-x])
for y in xrange(2 + n, size - n):
ret.append(array[-y][n])
return ret
حل تاني أقصر:
import numpy as np
def snail(array):
m = []
array = np.array(array)
while len(array) > 0:
m += array[0].tolist()
array = np.rot90(array[1:])
return m
https://www.codewars.com/kata/521c2db8ddc89b9b7a0000c1/train/python
الحل:
def snail(array):
ret = []
if array and array[0]:
size = len(array)
for n in xrange((size + 1) // 2):
for x in xrange(n, size - n):
ret.append(array[n][x])
for y in xrange(1 + n, size - n):
ret.append(array[y][-1 - n])
for x in xrange(2 + n, size - n + 1):
ret.append(array[-1 - n][-x])
for y in xrange(2 + n, size - n):
ret.append(array[-y][n])
return ret
حل تاني أقصر:
import numpy as np
def snail(array):
m = []
array = np.array(array)
while len(array) > 0:
m += array[0].tolist()
array = np.rot90(array[1:])
return m
😭8
كود ال bubble sort
#include <stdio.h>
// perform the bubble sort
void bubbleSort(int array[], int size) {
// loop to access each array element
for (int step = 0; step < size - 1; ++step) {
// loop to compare array elements
for (int i = 0; i < size - step - 1; ++i) {
// compare two adjacent elements
// change > to < to sort in descending order
if (array[i] > array[i + 1]) {
// swapping occurs if elements
// are not in the intended order
int temp = array[i];
array[i] = array[i + 1];
array[i + 1] = temp;
}
}
}
}
// print array
void printArray(int array[], int size) {
for (int i = 0; i < size; ++i) {
printf("%d ", array[i]);
}
printf("\n");
}
int main() {
int data[] = {-2, 45, 0, 11, -9};
// find the array's length
int size = sizeof(data) / sizeof(data[0]);
bubbleSort(data, size);
printf("Sorted Array in Ascending Order:\n");
printArray(data, size);
}
#include <stdio.h>
// perform the bubble sort
void bubbleSort(int array[], int size) {
// loop to access each array element
for (int step = 0; step < size - 1; ++step) {
// loop to compare array elements
for (int i = 0; i < size - step - 1; ++i) {
// compare two adjacent elements
// change > to < to sort in descending order
if (array[i] > array[i + 1]) {
// swapping occurs if elements
// are not in the intended order
int temp = array[i];
array[i] = array[i + 1];
array[i + 1] = temp;
}
}
}
}
// print array
void printArray(int array[], int size) {
for (int i = 0; i < size; ++i) {
printf("%d ", array[i]);
}
printf("\n");
}
int main() {
int data[] = {-2, 45, 0, 11, -9};
// find the array's length
int size = sizeof(data) / sizeof(data[0]);
bubbleSort(data, size);
printf("Sorted Array in Ascending Order:\n");
printArray(data, size);
}
فيديو مليح لشرح نهاية شابتر 4
https://www.youtube.com/watch?v=wE0_F4LpGVc
https://www.youtube.com/watch?v=wE0_F4LpGVc
YouTube
Abstract Classes And Pure Virtual Functions | C++ Tutorial
How and why to use abstract classes and pure virtual functions in C++. Source code: https://github.com/portfoliocourses/cplusplus-example-code/blob/main/abstract_class.cpp. Check out https://www.portfoliocourses.com to build a portfolio that will impress…
❤4
❤6
السلام عليكم
نبوا حد منزل كيمياء معمل لو عنده معلومه ان هل المنسقه نفسها وهل نقروا من نفس الشيت متع 18 الصفحه او لا
نبوا حد منزل كيمياء معمل لو عنده معلومه ان هل المنسقه نفسها وهل نقروا من نفس الشيت متع 18 الصفحه او لا
🔥7