Advertisement
Guest User

Untitled

a guest
Dec 29th, 2016
1,361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _08.condensed_Array_to_Number
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. string input = Console.ReadLine();
  14. string[] numbers = input.Split(' ');
  15. int[] array = new int[numbers.Length];
  16.  
  17. for (int i = 0; i < array.Length; i++)
  18. {
  19. array[i] = int.Parse(numbers[i]);
  20. }
  21.  
  22. int[] condensed = new int[array.Length - 1];
  23.  
  24. while (array.Length > 1)
  25. {
  26. for (int i = 0; i < array.Length - 1; i++)
  27. {
  28. condensed[i] = array[i] + array[i + 1];
  29. array[i] = condensed[i];
  30. }
  31. Array.Resize(ref condensed, condensed.Length - 1);
  32. Array.Resize(ref array, array.Length - 1);
  33. }
  34.  
  35. foreach (var element in array)
  36. {
  37. Console.WriteLine(element);
  38. }
  39. }
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement