javascritp—-將數字轉換成電子碼

來源:互聯網
上載者:User

早上在csdn瞎逛,突然發現一篇將資料轉換成電子碼的文章,吸引了我。作者是用java寫的,我稍微變通了一下,弄成javascript了,留著以後自己用。哈哈

  1. <script type="text/javascript">
  2. <!--
  3. function get(i) {  
  4. var graph = ""; 
  5. if (i != 1 && i != 4) {  
  6. graph = graph + " _";  
  7. }  
  8. if (i == 4 || i == 5 || i == 6 || i == 8 || i == 9) {  
  9. graph = graph + "/n|";  
  10. } else {  
  11. graph = graph + "/n ";  
  12. }  
  13. if (i != 1 && i != 7) {  
  14. graph = graph + "_";  
  15. } else {  
  16. graph = graph + " ";  
  17. }  
  18. if (i != 5 && i != 6) {  
  19. graph = graph + "|";  
  20. }
  21. if (i == 2 || i == 6 || i == 8) {  
  22. graph = graph + "/n|";  
  23. } else {  
  24. graph = graph + "/n ";  
  25. }  
  26. if (i != 1 && i != 4 && i != 7) {  
  27. graph = graph + "_";  
  28. } else {  
  29. graph = graph + " ";  
  30. }  
  31. if (i != 2) {  
  32. graph = graph + "|";  
  33. }  
  34. return graph;  
  35. ///alert(get(4))
  36. </script>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.