5. ข้อความ

The Camtasia Studio video content presented here requires JavaScript to be enabled and the latest version of the Macromedia Flash Player. If you are you using a browser with JavaScript disabled please enable it now. Otherwise, please update your version of the free Flash Player by downloading here.

 
รหัสที่ 5-20  ส่วนของโปรแกรมเข้ารหัสแบบ ROT-13 ที่ใช้ประมวลผลอักขระ
  for (int k=0; k<n; k=k+1) {   // แทนวงวนหลักในรหัสที่ 5-11
    char c = text.charAt(k);
    if       ('a' <= c && c <= 'm') c = (char)(c + 13);
    else if  ('n' <= c && c <= 'z') c = (char)(c - 13);
    else if  ('A' <= c && c <= 'M') c = (char)(c + 13);
    else if  ('N' <= c && c <= 'Z') c = (char)(c - 13);
    rot13 = rot13 + c;  // ใช้บวกต่อสตริงกับ char ได้ 
  }
©2009 S.Prasitjutrakul