Marcin Żuchelkowski

Marcin Żuchelkowski informatyk,
freelancer ... piszę
na prawie każdy
temat i ...

Temat: Wnioskowanie rozmyte w Lua, "dr. House" stawia diagnozę...

io.write('Software of the fuzzy logic... diagnosis of dr.House ...\n');
io.read();
io.write('What\'s your name darling??\n');
Name = io.read();
symptoms = {"high_temperature","red_nose","pain"};
diagnosisName = {"catarrh :","angina :","grippe :"}
x = {} ; y = {} ;diagnosis = {}; -- tworzenie macierzy
for i=1,3 do
x[i] = {} -- tworzenie kolumny
for j=1,3 do
x[i][j] = 0
end;
end;
diagnosis = {0,0,0};
x[1][1] = 10; x[2][2] = 80; x[1][3] = 30;
x[2][1] = 20; x[2][2] = 80; x[2][3] = 10;
x[3][1] = 10; x[3][2] = 70; x[3][3] = 80;

for i = 1,3 do
io.write(Name," enter value (0 to 100%) of ",symptoms[i]," :");
y[i]=tonumber(io.read());
end;

for i = 1,3 do
for j = 1,3 do
z = 0;
if (y[j] > x[j][i]) then z = tonumber(x[j][i]); else z = tonumber(y[j]); end;
if (z > diagnosis[i]) then diagnosis[i] = z; end;
end;
end;

z = 0;
for i = 1,3 do z=z+tonumber(diagnosis[i]); end;

io.write("\n");
io.write("Your dr. House tells you that you ",Name," have got ...\n");
for i = 1,3 do
io.write(diagnosisName[i],tostring((tonumber(diagnosis[i])/z)*100)," %\n");
end;
Michał T.

Michał T. IT / DTP-prepress
spec.

Temat: Wnioskowanie rozmyte w Lua, "dr. House" stawia diagnozę...

"diagnosis = {0,0,0};
x[1][1] = 10; x[2][2] = 80; x[1][3] = 30;
x[2][1] = 20; x[2][2] = 80; x[2][3] = 10;
x[3][1] = 10; x[3][2] = 70; x[3][3] = 80;"

Z programowania i z matmy jestem kiepski ale chyba masz błąd w adresowaniu tabeli.
Współrzędne x[1][1] = 10; x[1][2] = 80; x[1][3] = 30;

Napisałeś "x[1][1] = 10; x[2][2] = 80; x[1][3] = 30;"
Marcin Żuchelkowski

Marcin Żuchelkowski informatyk,
freelancer ... piszę
na prawie każdy
temat i ...

Temat: Wnioskowanie rozmyte w Lua, "dr. House" stawia diagnozę...

Masz absolutną rację
powinno być:
x[1][1] = 10; x[1][2] = 80; x[1][3] = 30;

czeski błąd

pzdr

Następna dyskusja:

House of cards- serial




Wyślij zaproszenie do