一道有趣的編程題

題目:實現字符串拼接 replace(replace(replace(replace(relatedzoneidinfo, '501', '0'), '502', '0'), '503', '0'), '504', '0')


答案:方案一:先組裝四個replace(,  + relatedzoneidinfo + 組裝四個 ,‘id’,'0')    

            總結:簡明易懂,需要兩個for循環


           方案二:result = "relatedzoneidinfo";

                          for (i =501; i<=504;i++)

                          {

                                 result = "replace("+result+",'i', '0')";

                          }

           總結:只需要一個for循環

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章