This commit is contained in:
ZennDev1337 2024-02-05 12:24:53 +01:00
parent 29ee27dbab
commit 3f5945ca8c
2 changed files with 5 additions and 5 deletions

View file

@ -7,11 +7,11 @@ void convert_char_to_ascii();
void print_type_size_bytes();
template <class T>
void bubble_sort(T *a)
void bubble_sort(int size, T *a)
{
for (int i = 0; i < sizeof(&a) / sizeof(a); i++)
for (int i = 0; i < size; i++)
{
for (int j = 0; j < 7 - 1 - i; j++)
for (int j = 0; j < size - 1 - i; j++)
{
if (a[j] > a[j + 1])
{
@ -29,7 +29,7 @@ void bubble_sort_print(int size, T *a)
for (int i = 0; i < size; i++)
std::cout << a[i] << ", ";
std::cout << "\n";
bubble_sort(a);
bubble_sort(size, a);
std::cout << "sorted Array: ";
for (int i = 0; i < size; i++)
std::cout << a[i] << ", ";

View file

@ -4,7 +4,7 @@
int main()
{
int demo[]{11, 14, 3, 18, 8, 17, 43, 6, 5, 4};
double demo2[]{11.2, 14.3, 3.2, 18.6, 8.7, 17.9, 43.3};
double demo2[]{11.2, 14.3, 3.2, 18.6, 8.7, 17.9, 43.3, 12.3};
// add_two_numbers();
// convert_char_to_ascii();
print_type_size_bytes();