Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace vectorsimatrici
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n,l,c;
- int[] a;//vectorul a
- int[,] m;//matricea m
- Console.WriteLine("Da-ti numarul de elemente:");
- n = int.Parse(Console.ReadLine());//n primeste sirul citit si convertit la int
- a = new int[n];//instantierea vectorului cu 100 de elemente
- for (int i = 0; i < n; i++)
- {
- Console.Write("a[" + i + "]");
- a[i] = int.Parse(Console.ReadLine());
- }
- //afisare
- for (int i = 0;i < a.Length;i++ )
- Console.Write(a[i] + " ");
- Console.WriteLine();
- //matricea
- m = new int[25, 25];
- Console.Write("Numar de linii=");
- l = int.Parse(Console.ReadLine());
- Console.Write("Numar de coloane=");
- c = int.Parse(Console.ReadLine());
- for (int i = 0; i < l; i++)
- for (int j = 0; j < c; j++)
- if (i == j)
- m[i, j] = 0;
- else
- if (i + j == l - 1)
- m[i, j] = 5;
- else
- if (i < j && j < l - i - 1)
- m[i, j] = 1;
- else
- if (i > j && j < l - i - 1)
- m[i, j] = 4;
- else
- if (i > j && j > l - i - 1)
- m[i, j] = 3;
- else
- m[i, j] = 2;
- for (int i = 0; i < l; i++)
- {
- for (int j = 0; j < c; j++)
- Console.Write(m[i, j] + " ");
- Console.WriteLine();
- }
- Console.Read();
- }
- }
- }
Add Comment
Please, Sign In to add comment