我的神经元算法
首先,这不是什么高深的有关人工智能的博客,只是一位初学者对自己的代码的生动的描述。因为一个有趣的油管博主 Tsoding Highlights 曾今说过:
I don't want to say reliable but one of the easiest solution for some of the real life problems is actually literally a mess like a literally a mess of neurons which we call a neural network. Okay, have you guys thought that a neural network is it basically a huge spaghetti code basically that is automatically written? like it's automatically generated spaghetti code. That's what neural networks are. So it turns out to be the best solution for a lot of problems.
所以,我借此为本文章命题,算是一个有趣的尝试
下文是一个非常简单的冒泡排序。
这是我人生写下的第一段算法程序,纯凭在脑中实物化指针与数组才有了下面的代码的诞生。
因此有点冗杂。不过,留着以后自己看看吧,那时希望我有别样的体会,感慨自己能够有所进步
#include <stdbool.h>
void print_array(int *, int, int);
// void sort(int * array, int size)
// {
// int p;
// for (int a = 0; a < size; a++)
// {
// for (int b = 0; b < (size - 1); b++)
// {
// if (array[b] < array[b + 1])
// {
// p = array[b];
// array[b] = array[b + 1];
// array[b + 1] = p;
// }
// }
// print_array(array, size, a);
// }
// }
void sort(int * array, int size)
{
// 降序排序函数
int p;
bool sorting_completed = false;
int sorted_number = 0;
int index = 0;
int count = 0;
while (!sorting_completed)
{
if (size > 1)
{
for(index = 0, sorted_number = 0; index < size - 1; index++)
{
if (array[index] < array[index + 1])
{
p = array[index];
array[index] = array[index + 1];
array[index + 1] = p;
}
if (array[size - 1 - index - 1] < array[size - 1 - index])
{
sorted_number--;
}
else
{
sorted_number++;
}
if (sorted_number == (size - 1))
{
sorting_completed = true;
}
}
}
else
{
sorting_completed = true;
}
print_array(array, size, count);
count++;
}
}
。。。

浙公网安备 33010602011771号