(**************************时间表排序***************************)
FOR x:= 1 TO i_ValidSystemNO BY 1 DO
FOR y:= 1 TO 50 BY 1 DO //执行50次排序
FOR z:= 1 TO 49 BY 1 DO
IF "DB_时间表C".TimeTableSystem[x].HourMinute[z]>="DB_时间表C".TimeTableSystem[x].HourMinute[z+1] THEN
HourMinuteValue:="DB_时间表C".TimeTableSystem[x].HourMinute[z];
ModeNoValue:="DB_时间表C".TimeTableSystem[x].ModeNO[z];
"DB_时间表C".TimeTableSystem[x].HourMinute[z]:="DB_时间表C".TimeTableSystem[x].HourMinute[z+1];
"DB_时间表C".TimeTableSystem[x].ModeNO[z]:="DB_时间表C".TimeTableSystem[x].ModeNO[z+1];
"DB_时间表C".TimeTableSystem[x].HourMinute[z+1]:=HourMinuteValue;
"DB_时间表C".TimeTableSystem[x].ModeNO[z+1]:=ModeNoValue;
END_IF;
END_FOR;
END_FOR;
END_FOR;
最佳答案
(**************************找最大值***************************)
FOR x:= 1 TO i_ValidSystemNO BY 1 DO
FOR z:= 1 TO 49 BY 1 DO
IF "DB_时间表C".TimeTableSystem[x].HourMinute[z]>="DB_时间表C".TimeTableSystem[x].HourMinute[z+1] THEN
HourMinuteValue:="DB_时间表C".TimeTableSystem[x].HourMinute[z];
ModeNoValue:="DB_时间表C".TimeTableSystem[x].ModeNO[z];
"DB_时间表C".TimeTableSystem[x].HourMinute[z]:="DB_时间表C".TimeTableSystem[x].HourMinute[z+1];
"DB_时间表C".TimeTableSystem[x].ModeNO[z]:="DB_时间表C".TimeTableSystem[x].ModeNO[z+1];
"DB_时间表C".TimeTableSystem[x].HourMinute[z+1]:=HourMinuteValue;
"DB_时间表C".TimeTableSystem[x].ModeNO[z+1]:=ModeNoValue;
END_IF;
END_FOR;
END_FOR;
这不是排序,只是找最大值,而且只是找XZ二维数组的最大值,Y循环是多余的。
提问者对于答案的评价:
谢谢
原创文章,作者:more0621,如若转载,请注明出处:https://www.zhaoplc.com/plc284235.html