Who can give me a full answer of this question?
조회 수: 5 (최근 30일)
이전 댓글 표시
Write a program which repeatedly reads numbers until the user enters "done". Once "done" is entered, print out the Max and Min. Use an array to store all the numbers. Example of execution:
Enter a number: 4
Enter a number: 5
Enter a number: 9
Enter a number: done
Max = 9, Min = 4
댓글 수: 12
Stephen23
2017년 5월 22일
편집: Stephen23
2017년 5월 22일
@Emma Swaggy: well, you made me laugh, which is a fine thing indeed.
Most of us here will not do other people's homework, but we are all happy to help you if you have specific questions about MATLAB, or are unsure how to approach solving a problem. In return you have to put in the effort yourself and show some initiative: for example MATLAB has very readable documentation which is easy to search using [your favorite internet search engine]. The documentation also includes working examples for almost every operation and function: the more you try yourself the more you will learn, the more you will understand, and the easier it will be for us to help you. We are not babysitters, nor a free tutor service, nor are we going to write all of your homework for you.
But please do ask us questions about how to use MATLAB.
You should start by doing the introductory tutorials (yes, really):
답변 (2개)
KSSV
2017년 5월 22일
For your work..you have to read about
1. input
2. min and max
3. disp
댓글 수: 3
KSSV
2017년 5월 22일
@ Emma Swaggy....this is what we want here..you try out and have a problem then pose the question,, people would be happy to help/ answer you.
Thomas Nguyen
2018년 4월 7일
@EmmaSwaggy: next time you could search google :p it's really simple just find the keywords (For example here it's quite simple to spot out the keywords are min, max, input (like @KSSV said) ) then add "matlab" either the beginning or end :p
Thomas Nguyen
2018년 4월 8일
Code:
function[] = someonesHW()
idx=1;
prompt='Enter a number: ';
while true
inp=input(prompt,'s');
if (inp=="done")
break;
else
a=str2double(inp);
if isempty(a)
disp('Invalid input!');
continue
elseif isnumeric(a)==1
A(idx)=a;
idx=idx+1;
end
end
end
Min=min(A(:));
Max=max(A(:));
disp(['Max = ',num2str(Max),'; Min = ',num2str(Min)]);
end%someonesHW()
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!