Vous êtes sur la page 1sur 9

exercicio 1

static void Main(string[] args)


{
int[,] x = new int[3,3];
int l, c, soma = 0;
for(l=0;l<=2;l++)
for (c = 0; c <= 2; c++)
{
Console.WriteLine("x[{0},{1}]=", l, c);
x[l, c] = int.Parse(Console.ReadLine());
soma += x[l, c];
}
Console.WriteLine("somatoria = {0}", soma);
Console.ReadLine();
}
}
}

exercicio 2
static void Main(string[] args)
{
int[,] x = new int[5,3];
int l, c, maior = 0,pL=0,pC=0;
for(l=0;l<=4;l++)
for (c = 0; c <= 2; c++)
{
Console.WriteLine("x[{0},{1}]=", l, c);
x[l, c] = int.Parse(Console.ReadLine());
if (x[l, c] > maior)
{
maior = x[l, c];
pL = l;
pC = c;
}
}
Console.WriteLine("maior elemento = {0}, na linha {1} , coluna {2}",
maior,pL,pC);
Console.ReadLine();
}
}
}
exercicio 3
static void Main(string[] args)
{
int[,] x = new int[5,3];
int l, c, maior = 0,pL=0,pC=0;
for(l=0;l<=4;l++)
for (c = 0; c <= 2; c++)
{
Console.WriteLine("x[{0},{1}]=", l, c);
x[l, c] = int.Parse(Console.ReadLine());

if (x[l, c] > maior)


maior = x[l, c];
}
for(l=0;l<=4;l++)
for (c = 0; c <= 2; c++)
{
if (maior == x[l, c])
Console.WriteLine("maior elemento = {0} encontr
ado , na linha {1} , coluna {2}", maior, l, c);
}
Console.ReadLine();
}
}
}

exercicio 4
static void Main(string[] args)
{
int[,] x = new int[3,4];
int l, c;
for(l=0;l<=2;l++)
for (c = 0; c <= 3; c++)
{
Console.WriteLine("x[{0},{1}]=", l, c);
x[l, c] = int.Parse(Console.ReadLine());
x[l, c] = x[l, c] * l;
}
for(l=0;l<=2;l++)
for (c = 0; c <= 3; c++)
Console.WriteLine("x[{0},{1}]={2}",l,c,x[l,c]);
Console.ReadLine();
}
}
}

exercicio 5
static void Main(string[] args)
{
double[,] a = new double [4,4],b=new double [4,4],s=new double [4,4]
;
int l, c;
for(l=0;l<=3;l++)
for (c = 0; c <= 3; c++)
{
Console.WriteLine("a[{0},{1}]=", l, c);
a[l, c] = Double.Parse(Console.ReadLine());

Console.WriteLine("b[{0},{1}]=", l, c);
b[l, c] = Double.Parse(Console.ReadLine());
s[l, c] = a[l, c] + b[l, c];
}
for(l=0;l<=3;l++)
for (c = 0; c <= 3; c++)
Console.WriteLine("s[{0},{1}]={2}",l,c,s[l,c]);
Console.ReadLine();
}
}
}

exercicio 6
static void Main(string[] args)
{
int[,] x = new int[5, 5];
int l, c, soma = 0;
for(l=0;l<=4;l++)
for (c = 0; c <= 4; c++)
{
Console.WriteLine("x[{0},{1}]=", l, c);
x[l, c] = int.Parse(Console.ReadLine());
if (l == c)
soma += x[l, c];
}
Console.WriteLine("somatoria diagonal principal = {0}", soma);
Console.ReadLine();
}
}
}

exercicio 7
static void Main(string[] args)
{
int[,] x = new int[5, 5];
int l, c, soma = 0;
for (l = 0; l <= 4; l++)
for (c = 0; c <= 4; c++)
{
Console.WriteLine("x[{0},{1}]=", l, c);
x[l, c] = int.Parse(Console.ReadLine());
if (l+c == 4)
soma += x[l, c];
}
Console.WriteLine("somatoria diagonal secundaria = {0}", soma);
Console.ReadLine();
}
}
}

exercicio 8
static void Main(string[] args)
{
int[,] x = new int[5, 5];
int l, c, soma = 0;
for (l = 0; l <= 4; l++)
for (c = 0; c <= 4; c++)
{
Console.WriteLine("x[{0},{1}]=", l, c);
x[l, c] = int.Parse(Console.ReadLine());
if (l == c-1||l==c||l==c+1)
soma += x[l, c];
}
Console.WriteLine("somatoria = {0}", soma);
Console.ReadLine();
}
}
}

exercicio 09
static void Main(string[] args)
{
int[,] a = new int[4, 4];
int[] b = new int[4];
int l, c;
for (l = 0; l <= 3; l++)
for (c = 0; c <= 3; c++)
{
Console.WriteLine("a[{0},{1}]=", l, c);
a[l, c] = int.Parse(Console.ReadLine());
if (l == c)
b[l] = a[l, c];
}
for (c = 0; c <= 3; c++)
Console.WriteLine("b[{0}]={1}", c, b[c]);
Console.ReadLine();
}
}
}
exercicio 10
static void Main(string[] args)
{
int[,] a = new int[4, 4];
int[] b = new int[4];
int l, c;
for (l = 0; l <= 3; l++)
for (c = 0; c <= 3; c++)
{
Console.WriteLine("a[{0},{1}]=", l, c);

a[l, c] = int.Parse(Console.ReadLine());
if (l+c == 3)
b[l] = a[l,c];
}
for (c = 0; c <= 3; c++)
Console.WriteLine("b[{0}]={1}", c, b[c]);
Console.ReadLine();
}
}
}
exercicio 11
static void Main(string[] args)
{
int[,] a = new int[5,5];
int l, c,somaSup=0,somaInf=0;
for (l = 0; l <= 4; l++)
for (c = 0; c <=4; c++)
{
Console.WriteLine("a[{0},{1}]=", l, c);
a[l, c] = int.Parse(Console.ReadLine());
if (l < c)
somaSup += a[l,c];
if (l > c)
somaInf += a[l, c];
}
Console.WriteLine("soma superior= {0},soma inferior= {1}",somaSup,so
maInf);
Console.ReadLine();
}
}
}
exercicio 12
static void Main(string[] args)
{
string[,] a = new string[4,4],t=new string[4,4];
int l, c;
for (l = 0; l <= 3; l++)
for (c = 0; c <= 3; c++)
{
Console.WriteLine("a[{0},{1}]=", l, c);
a[l, c] = Console.ReadLine();
t[c, l] = a[l, c];
}
for (l = 0; l <= 3; l++)
for (c = 0; c <= 3; c++)
Console.WriteLine("t[{0},{1}]={2}", l, c, t[l, c]);
Console.ReadLine();
}
}
}

exercicio 14
static void Main(string[] args)
{
double[,] a = new double[5, 5];
double[] b = new double[5];
int l, c;
for (c = 0; c <= 4; c++)
b[c] = 0;
for(l=0;l<=4;l++)

for(c = 0; c <= 4; c++)


{
a[l, c] = l * 5 + c + 1;
Console.WriteLine("a[{0},{1}]={2}", l, c, a[l, c]);
b[c] += a[l, c];
}
for (c = 0; c <= 4; c++)
Console.WriteLine("b[{0}]={1}", c, b[c]);
Console.ReadLine();
}
}
}
exercicio 15
static void Main(string[] args)
{
int [,] a = new int[3, 3];
int [] b = new int[3];
int l, c;
for (c = 0; c <= 2; c++)
b[c] =c+1;
for(l=0;l<=2;l++)
for(c = 0; c <= 2; c++)
{
a[l, c] = l * 3 + c + 1;
Console.WriteLine("a[{0},{1}]={2}", l, c, a[l, c]);
a[l,c] += b[c];
}
for(l=0;l<=2;l++)
for (c = 0; c <= 2; c++)
Console.WriteLine("a[{0},{1}]={2}",l,c, a[l, c]);
Console.ReadLine();
}
}
}

exercicio 16
static void Main(string[] args)
{
int[,] a = new int[6, 3];
int l, c,aux=0;
for(l=0;l<=5;l++)
for(c = 0; c <= 2; c++)
{
a[l, c] = l * 3 + c + 1;
Console.WriteLine("a[{0},{1}]={2}", l, c, a[l, c]);
}
for (l = 0; l <= 2; l++)

for (c = 0; c <= 2; c++)


{
aux = a[l, c];
a[l, c] = a[5 - l, c];
a[5 - l, c] = aux;
}
for (l = 0; l <= 5; l++)
for (c = 0; c <= 2; c++)
Console.WriteLine("a[{0},{1}]={2}", l, c, a[l, c]);
Console.ReadLine();
}
}
}
exercicio 17
static void Main(string[] args)
{
int[,] a = new int[6, 3];
int l, c,aux=0;
for(l=0;l<=5;l++)
for(c = 0; c <= 2; c++)
{
a[l, c] = l * 3 + c + 1;
Console.WriteLine("a[{0},{1}]={2}", l, c, a[l, c]);
}
for (l = 0; l <= 2; l++)
for (c = 0; c <= 2; c++)
{
aux = a[l, c];
a[l, c] = a[3 + l, c];
a[3 + l, c] = aux;
}
for (l = 0; l <= 5; l++)
for (c = 0; c <= 2; c++)
Console.WriteLine("a[{0},{1}]={2}", l, c, a[l, c]);
Console.ReadLine();
}
}
}
exercicio 18
static void Main(string[] args)
{
bool[,] a = new bool[5, 12];
int l, c,contPol=0;

for (l = 0; l <= 4; l++)


for (c = 0; c <= 11; c++)
a[l, c] = true;
Console.WriteLine("digite as cordenadas da poltrona");
l=int.Parse(Console.ReadLine());
c=int.Parse(Console.ReadLine());
while(l>=0 && c>=0)
{
if (a[l,c] == true)
{
a[l, c] = false;
Console.WriteLine("reserva confirmada");
contPol += 1;
}
else
Console.WriteLine(" a poltrona ja esta reservada");
Console.WriteLine("digite as cordenadas da poltrona");
l=int.Parse(Console.ReadLine());
c=int.Parse(Console.ReadLine());
}
Console.WriteLine(" a quantidade de poltronas reservadas eh = {0
}",contPol);
Console.ReadLine();
}
}
}