#include <a_samp>
enum LIST_INFO
{
l_int,
l_str[10],
Float:l_float
}
new List[][LIST_INFO] = {
{2,"Test2",2.2},
{1,"Test1",1.1},
{4,"Test4",4.4},
{3,"Test3",3.3},
{5,"Test5",5.5}
};
stock BubbleSort(array[][LIST_INFO],index = 0,start = 0,len = sizeof(array),len2 = sizeof(array[]))
{
for(new i=start;i<len-1+start;i++)
{
for(new j=start;j<len-1-i+start;j++)
{
if(array[j+1][LIST_INFO:index] < array[j][LIST_INFO:index])
{
new temp[LIST_INFO];
for(new t;t<len2;t++)
{
temp[LIST_INFO:t] = array[j+1][LIST_INFO:t];
array[j+1][LIST_INFO:t] = array[j][LIST_INFO:t];
array[j][LIST_INFO:t] = temp[LIST_INFO:t];
}
}
}
}
return 1;
}
public OnFilterScriptInit()
{
BubbleSort(List);
for(new i;i<sizeof(List);i++) printf("%d %s %.f",List[i][l_int],List[i][l_str],List[i][l_float]);
return 1;
}
#include <a_samp>
enum LIST_INFO
{
l_int,
l_str[10],
Float:l_float
}
new List[][LIST_INFO] = {
{2,"Test2",2.2},
{1,"Test1",1.1},
{4,"Test4",4.4},
{3,"Test3",3.3},
{5,"Test5",5.5}
};
stock BubbleSort(array[][LIST_INFO],enum ENUM_NAME,index = 0,start = 0,len = sizeof(array),len2 = sizeof(array[]))
{
for(new i=start;i<len-1+start;i++)
{
for(new j=start;j<len-1-i+start;j++)
{
if(array[j+1][ENUM_NAME:index] < array[j][ENUM_NAME:index])
{
new temp[LIST_INFO];
for(new t;t<len2;t++)
{
temp[ENUM_NAME:t] = array[j+1][ENUM_NAME:t];
array[j+1][ENUM_NAME:t] = array[j][ENUM_NAME:t];
array[j][ENUM_NAME:t] = temp[ENUM_NAME:t];
}
}
}
}
return 1;
}
public OnFilterScriptInit()
{
BubbleSort(List,LIST_INFO);
for(new i;i<sizeof(List);i++) printf("%d %s %.f",List[i][l_int],List[i][l_str],List[i][l_float]);
return 1;
}
C:\Users\Atoma_000\Desktop\samp03z\filterscripts\b ub.pwn(17) : error 010: invalid function or declaration C:\Users\Atoma_000\Desktop\samp03z\filterscripts\b ub.pwn(17) : error 017: undefined symbol "ENUM_NAME" C:\Users\Atoma_000\Desktop\samp03z\filterscripts\b ub.pwn(17) : error 010: invalid function or declaration C:\Users\Atoma_000\Desktop\samp03z\filterscripts\b ub.pwn(17 -- 19) : fatal error 107: too many error messages on one line Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 4 Errors. |
enum eListInfo
{
l_int,
l_str[10],
Float:l_float
}
new List[][eListInfo] = {
{2,"Test2",2.2},
{1,"Test1",1.1},
{4,"Test4",4.4},
{3,"Test3",3.3},
{5,"Test5",5.5}
};
BubbleSort(array[][], idx = 0, start = 0, len = sizeof(array)) { // code from wikipedia
new
i,
l
;
len--;
do {
for(l = 0, i = start; i < len; ++i) {
if(array[i + 1][idx] < array[i][idx]) {
ExchangeArraySlots(array, i + 1, (l = i)); // taken from md-sort by Slice
// https://sampforum.blast.hk/showthread.php?tid=343172
}
}
} while((len = l));
}
enum eListInfo { l_int, l_str[10], Float:l_float }
new List[][eListInfo] = {
{2,"Test2",2.2},
{1,"Test1",1.1},
{4,"Test4",4.4},
{3,"Test3",3.3},
{5,"Test5",5.5}
};
enum eDataInfo { d_int, d_str[10], Float:d_float }
new Data[][eDataInfo] = {
{7,"Test3",1.1},
{4,"Test2",8.8},
{2,"Test5",3.3},
{8,"Test6",5.5},
{6,"Test9",7.7}
};
public OnFilterScriptInit() {
BubbleSort(List, l_int);
for(new i;i<sizeof(List);i++) printf("%d %s %.f",List[i][l_int],List[i][l_str],List[i][l_float]);
BubbleSort(Data, d_float);
for(new i;i<sizeof(Data);i++) printf("%d %s %.f",Data[i][d_int],Data[i][d_str],Data[i][d_float]);
}
#include <a_samp>
enum eLIST_INFO
{
l_int,
l_str[10],
Float:l_float
}
new List[][eLIST_INFO] = {
{2,"Test2",2.2},
{1,"Test1",1.1},
{4,"Test4",4.4},
{3,"Test3",3.3},
{5,"Test5",5.5}
};
stock BubbleSort(array[][],index = 0,start = 0,len = sizeof(array),len2 = sizeof(array[]))
{
for(new i=start;i<len-1+start;i++)
{
for(new j=start;j<len-1-i+start;j++)
{
if(array[j+1][index] < array[j][index])
{
for(new t;t<len2;t++)
{
new temp = array[j+1][t];
array[j+1][t] = array[j][t];
array[j][t] = temp;
}
}
}
}
return 1;
}
public OnFilterScriptInit()
{
BubbleSort(List,l_int);
for(new i;i<sizeof(List);i++) printf("%d %s %.f",List[i][l_int],List[i][l_str],List[i][l_float]);
return 1;
}