Guest User

Untitled

a guest
Jan 21st, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace vectorsimatrici
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. int n,l,c;
  13. int[] a;//vectorul a
  14. int[,] m;//matricea m
  15.  
  16. Console.WriteLine("Da-ti numarul de elemente:");
  17. n = int.Parse(Console.ReadLine());//n primeste sirul citit si convertit la int
  18. a = new int[n];//instantierea vectorului cu 100 de elemente
  19. for (int i = 0; i < n; i++)
  20. {
  21. Console.Write("a[" + i + "]");
  22. a[i] = int.Parse(Console.ReadLine());
  23. }
  24. //afisare
  25. for (int i = 0;i < a.Length;i++ )
  26. Console.Write(a[i] + " ");
  27. Console.WriteLine();
  28. //matricea
  29. m = new int[25, 25];
  30. Console.Write("Numar de linii=");
  31. l = int.Parse(Console.ReadLine());
  32. Console.Write("Numar de coloane=");
  33. c = int.Parse(Console.ReadLine());
  34. for (int i = 0; i < l; i++)
  35. for (int j = 0; j < c; j++)
  36. if (i == j)
  37. m[i, j] = 0;
  38. else
  39. if (i + j == l - 1)
  40. m[i, j] = 5;
  41. else
  42. if (i < j && j < l - i - 1)
  43. m[i, j] = 1;
  44. else
  45. if (i > j && j < l - i - 1)
  46. m[i, j] = 4;
  47. else
  48. if (i > j && j > l - i - 1)
  49. m[i, j] = 3;
  50. else
  51. m[i, j] = 2;
  52. for (int i = 0; i < l; i++)
  53. {
  54. for (int j = 0; j < c; j++)
  55. Console.Write(m[i, j] + " ");
  56. Console.WriteLine();
  57. }
  58.  
  59. Console.Read();
  60. }
  61. }
  62. }
Add Comment
Please, Sign In to add comment