test_sort.m

来自「matlab源代码,适用于开发研究,带来很好的学习效果.」· M 代码 · 共 22 行

M
22
字号
% Script file test_sort.m
% 
% Purpose:
%   To read in an input data set,sort it into ascending order
% using the selection sort algorithm,and to write the sorted dat
% to the command window.
%  This program calls function "ssort" to do the actual sorting.

nvals=input('Enter number of the numbers to sort:');
array=zeros(1,nvals);
for ii=1:nvals
    string=['Enter value ' int2str(ii) ':'];
        array(ii)=input(string);    
end
    sorted=ssort(array);
    fprintf('\n sorted data:\n');
    for ii=1:nvals
        fprintf('%8.4f\n',sorted(ii));
    end 


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?