fork download
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. public class Test
  5. {
  6. static int ToInt( int[] arr )
  7. {
  8. int len = arr.Length;
  9. int res = 0;
  10. for( int i = 0; i<len; ++i )
  11. {
  12. res += arr[i];
  13. res *= 10;
  14. }
  15. return res/10;
  16. }
  17.  
  18. static int[] ToArray( int i )
  19. {
  20. List<int> lst = new List<int>();
  21. if( i == 0 ) lst.Add(0);
  22. while( i != 0 )
  23. {
  24. lst.Add( i %10 );
  25. i /= 10;
  26. }
  27.  
  28. lst.Reverse();
  29. return lst.ToArray();
  30. }
  31.  
  32. public static void Main()
  33. {
  34. int[] a = {2,5,4,3};
  35. int[] b = {3,9,1};
  36.  
  37. //Console.WriteLine( ToInt( a ) );
  38. //Console.WriteLine( ToInt( b ) );
  39.  
  40. Console.WriteLine( ToInt( ToArray( ToInt( a ) + ToInt( b ) ) ) );
  41. }
  42. }
Success #stdin #stdout 0.03s 33888KB
stdin
Standard input is empty
stdout
2934