Write a script for the problem.
信息
此问题已关闭。 请重新打开它进行编辑或回答。
显示 更早的评论
(a) A machine cuts N pieces of a pipe. After each cut, each piece of pipe is weighed and its length is measured; these 2 values are then stored in a file called pipe.dat (first the weight and then the length on each line of the file). Ignoring units, the weight is supposed to be between 2.1 and 2.3, inclusive, and the length is supposed to be between 10.3 and 10.4, inclusive. The following is just the beginning of what will be a long script to work with these data. For now, the script will just count how many rejects there are. A reject is any piece of pipe that has an invalid weight and/or length. For a simple example ‐if N is 3 (meaning three lines in the file) and the file stores: 2.14 10.30 2.32 10.36 2.20 10.35 there is only one reject, the second one, as it weighs too much. The script would print: There were 1 rejects.
(b) Improve the output from the previous problem. If there is only 1 reject, it should print “There was 1 reject.”; otherwise for n rejects it should print “There were n rejects.”
0 个评论
回答(1 个)
Chad Greene
2015-10-29
0 个投票
0 个评论
此问题已关闭。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!