Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
886 B

  1. /*
  2. *
  3. * Original Javascript version by David Hedbor(http://www.bagley.org/~doug/shootout/)
  4. *
  5. */
  6. local SIZE=30;
  7. function mkmatrix(rows, cols) {
  8. local i, j, count = 1;
  9. local m = []; m.resize(rows);
  10. for (i = 0; i < rows; i+=1) {
  11. m[i] = [];m[i].resize(cols)
  12. for (j = 0; j < cols; j+=1) {
  13. m[i][j] = count+=1;
  14. }
  15. }
  16. return m;
  17. }
  18. function mmult(rows, cols, m1, m2, m3) {
  19. local i, j, k, val;
  20. for (i = 0; i < rows; i+=1) {
  21. for (j = 0; j < cols; j+=1) {
  22. val = 0;
  23. for (k = 0; k < cols; k+=1) {
  24. val += m1[i][k] * m2[k][j];
  25. }
  26. m3[i][j] = val;
  27. }
  28. }
  29. return m3;
  30. }
  31. local n = ARGS.len()!=0?ARGS[0].tointeger():1
  32. local m1 = mkmatrix(SIZE, SIZE);
  33. local m2 = mkmatrix(SIZE, SIZE);
  34. local mm = mkmatrix(SIZE, SIZE);
  35. for (local i = 0; i < n; i+=1) {
  36. mmult(SIZE, SIZE, m1, m2, mm);
  37. }
  38. print(mm[0][0]+" "+mm[2][3]+" "+mm[3][2]+" "+mm[4][4]);