<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 用tab替換行輸入中的4個連續(xù)blank

          用tab替換行輸入中的4個連續(xù)blank

          作者: 時間:2016-11-28 來源:網(wǎng)絡(luò) 收藏
          這是一道書中的題: Write a program entab that replaces strings of blanks by the minimum number of tabs and blanks to achieve the same spacing. Use the same tab stops as for detab. When either a tab or a single blank would suffice to reach a tab stop, which should be given preference?
          自己思考了很久,可能對題目理解有錯。但難得找到方法,記一下:
          1.一開始,在輸入時就進行識別,想在輸入存入數(shù)組前用tab代替連續(xù)的blank。以目前水平感覺實現(xiàn)起來有技術(shù)難度,還容易操作數(shù)組越界,導致core dump。改正也不知從何下手。
          2.改變大方向,先把所有的輸入保存到數(shù)組里,再對數(shù)組元素逐個識別、替換。很快大的框架就實現(xiàn)了,剩下就是解決邏輯錯誤帶來的錯誤結(jié)果。
          程序:






          總結(jié):
          <45><46>兩行花的時間最多,還是要看著結(jié)果,順著程序一遍一遍在腦里過,沒有捷徑。想不通時放一放。


          關(guān)鍵詞: tab行輸入blan

          評論


          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();