当前位置:首页 > MATLAB期末考试试卷及其参考答案[1]
.
str2 = input('No.:'); %for k=1:2
% val(k,:) = input('Curriculums and Scores:'); % a(k,1)=val{k,2}; %end
%val(1,:) = input('Curriculum:'); %val(:,2) = input('Scores:');
val = input('please input five Curriculums and Scores:'); for k=1:5
a(k,1)=val{k,2}; end
student(i).Name = str1; student(i).No = str2; student(i).Scores = val; student(i).Ave = mean(a); end
for ii= 1:(length(student)-1) iptr = ii;
for jj=ii+1 : length(student)
if (student(jj).Ave > student(iptr).Ave) iptr = jj; end end
if ii ~=iptr
temp = student(ii);
student(ii) =student(iptr); student(iptr) = temp; end end
for ii=1 : length(student) if student(ii).Ave > 80 disp(student(ii).Name); disp(student(ii).Ave); end end
disp(['student average']);disp(' ')
name',blanks(6),'student
no.',blanks(6),'student
for ii=1 : length(student)
disp([student(ii).Name,blanks(20),student(ii).No,blanks(20),num2str(s
;..
.
tudent(ii).Ave)]); end
;..
共分享92篇相关文档