(5.4)--5.4Processingofasetofstringdata.pdf
《(5.4)--5.4Processingofasetofstringdata.pdf》由会员分享,可在线阅读,更多相关《(5.4)--5.4Processingofasetofstringdata.pdf(7页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。
1、Processing of a set of string dataProcessing of a set of string data5.4EgEnter M strings from the keyboard,compare their length and output the longest string.Problem solving using computational thinking:Suppose that there are M stringsin total,and the maximum length of each string is N characters.So
2、lving this problemcould be divided into three steps.Step 1:Input all M strings iteratively,and assume thatthe longest string is the first string;Step 2:Find out the longest string iteratively;Step3:Output the longest string and its length.Processing of a set of string data5.4StepProcessing1Iterative
3、ly input all M strings;and assume that the t-th string is the longest,initially set t=1.2Let i range from 2 to M.perform the following operations on the following M-1 strings:If the length of the i-th string is greater than the length of the t-th stringThen t=i3Output the t-th string and its lengthP
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 5.4 Processingofasetofstringdata
限制150内