Question for Pascal users?

1 次查看(过去 30 天)
Juan
Juan 2018-3-16
编辑: Juan 2018-3-16
I have a job application in which I need to solve an easy problem through programing. I've solved it through Matlab (my favourite software for these kind of problems) but they asked me to write it for Pascal software. I've never used that program and I'm stuck.
If someone knows Pascal language could you please translate the following code? It's really easy and short.
I thank you in advance
function [CT] = CostoTotal(U)
F(1)=0;
CE =0;
for dia=1:365
for hora=1:24
if hora<=7 & hora>=23
precio_horario=60*rand;
else
precio_horario=120*rand;
end
if precio_horario >= U
P=0;
else
P=1;
end
F(hora + (dia-1)*24 + 1)= F(hora + (dia-1)*24) + 1-P*5;
CE=CE + precio_horario*P;
end
end
cpp = sumsqr(max(F,0))*1000/8760;
CT = CE + cpp;

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by