fork(1) download
  1. class VIP.LebenshteinDistance: GLib.Object {
  2. private int lebenshtein_distance(string s, string t) {
  3. int[,] d = new int[s.length + 1, t.length + 1];
  4. for (int i = 0; i <= s.length; i++)
  5. d[i, 0] = i;
  6. for (int j = 0; j <= t.length; j++)
  7. d[0, j] = j;
  8. for (int j = 1; j <= t.length; j++) {
  9. for (int i = 1; i <= s.length; i++) {
  10. int cost = (s[i - 1] == t[j - 1]) ? 0 : 1;
  11. d[i, j] = int.min(int.min(d[i - 1, j] + 1, d[i, j - 1] + 1), d[i - 1, j - 1] + cost);
  12. }
  13. }
  14. return d[s.length, t.length];
  15. }
  16.  
  17. public static int main(string[] args) {
  18. string? name1 = stdin.read_line();
  19. string? name2 = stdin.read_line();
  20.  
  21. if (name1 != null && name2 != null) {
  22. var ld = new LebenshteinDistance();
  23. if (ld.lebenshtein_distance(name1, name2) <= 1)
  24. stdout.printf("same person\n");
  25. else
  26. stdout.printf("different persons\n");
  27. }
  28.  
  29. return 0;
  30. }
  31. }
  32.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(1,9): error CS1525: Unexpected symbol `.', expecting `(', `:', `{', or `where'
Compilation failed: 1 error(s), 0 warnings
stdout
Standard output is empty