



Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity
Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium
Esta página no es visible en la vista previa
¡No te pierdas las partes importantes!




function [triangle, size] = obtainTriangle(matrix, side) size = 0; for (i=1:side) size = size + i; end triangle = zeros(1,size); el = 1; for (i=1:side) for (j=1:side+1-i) triangle(el) = matrix(i,j); el = el + 1; end end end
function triangle = sort(triangle,size) for i = 1:(size - 1) for j = 1:(size - i) % comparison index^th with (index + 1)^th if ( triangle(j) > triangle(j+1) ) % swap the content of the two positions a = triangle(j); triangle(j) = triangle(j+1); triangle(j+1) = a; end end end end
%Section C function cheapestSupermarkets = obtainCheapest(supermarkets, productId, priceMax) numSuper = 5; numProducts= 100;
cheapestSupermarkets = zeros(1,numSuper);
j=1; for i = 1:numSuper if ((supermarkets(i).products(productId).price)