fork(3) download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. private static int convert(string s) {
  6. int res = 0;
  7. foreach (var c in s) {
  8. int d = c - 'A' + 1;
  9. res = 26 * res + d;
  10. }
  11. return res;
  12. }
  13. public static void Main()
  14. {
  15. var ss = new[] {
  16. "A", "B", "C", "Y", "Z", "AA", "AB", "AC", "AZ", "ZY", "ZZ", "AAA"
  17. };
  18. foreach (var s in ss) {
  19. Console.WriteLine("{0} - {1}", s, convert(s));
  20. }
  21. }
  22. }
Success #stdin #stdout 0.03s 33928KB
stdin
Standard input is empty
stdout
A - 1
B - 2
C - 3
Y - 25
Z - 26
AA - 27
AB - 28
AC - 29
AZ - 52
ZY - 701
ZZ - 702
AAA - 703