Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Bounce
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. string values = Console.ReadLine();
  10. string[] tokens = values.Split(' ');
  11.  
  12. int[] convertedItems = Array.ConvertAll<string, int>(tokens, int.Parse);
  13.  
  14. int n = convertedItems[0];
  15. int m = convertedItems[1];
  16. //declare matrix
  17. int[,] matrix = new int[n, m];
  18. var sum = 0;
  19. //fill matrix with correct vallues
  20. for (int row = 0; row < n; row++)
  21. {
  22. for (int col = 0; col < m; col++)
  23. {
  24. matrix[row, col] = (int)Math.Pow(2, row + col);
  25. }
  26. }
  27.  
  28. Print(matrix);
  29. Console.WriteLine(sum);
  30. }
  31.  
  32. static void Print(int[,] matrixToPrint)
  33. {
  34. for (int row = 0; row < matrixToPrint.GetLength(0); row++)
  35. {
  36. for (int col = 0; col < matrixToPrint.GetLength(1); col++)
  37. {
  38. Console.Write(matrixToPrint[row, col] + " ");
  39. }
  40. Console.WriteLine();
  41. }
  42. }
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement