miércoles, 9 de diciembre de 2009

Practica 11.1 Consola

PSEUDOCODIGO

int[,] num = {{ 16, 22, 99, 4, 18 },{ -258, 4, 101, 5, 98 },{ 105, 6, 15, 2, 45 },{ 33, 88, 72, 16, 3 }};
int Mayor = num[0, 0];
int posR = 0, posC = 0, R, C;
for (R = 0; R <4; R++)
{
for (C = 0; C <5 ; C++)
{
if (num[R, C] > Mayor)
{
posR = R;
posC = C;
Mayor = num[R, C];
}
}
}
for (R = 0; R < 4; R++)
{
for (C = 0; C < 5; C++)
{
print num[R, C]);
}
print Mayor
print posR+1
print posC+1

FIN




using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PRACTICA_11_1C
{
class Program
{
static void Main(string[] args)
{
int[,] num = {{ 16, 22, 99, 4, 18 },{ -258, 4, 101, 5, 98 },{ 105, 6, 15, 2, 45 },{ 33, 88, 72, 16, 3 }};
int Mayor = num[0, 0];
int posR = 0, posC = 0, R, C;
for (R = 0; R <4; R++)
{
for (C = 0; C <5 ; C++)
{
if (num[R, C] > Mayor)
{
posR = R;
posC = C;
Mayor = num[R, C];
}
}
}
for (R = 0; R < 4; R++)
{
for (C = 0; C < 5; C++)
{
Console.Write("\t{0}", num[R, C]);
}
Console.WriteLine();
}
Console.WriteLine("El dato mayor es: {0}", Mayor);
Console.WriteLine("En el renglon: {0}", posR+1);
Console.WriteLine("Y la columna: {0}", posC+1);

Console.ReadKey();


}
}
}
[p11.1.jpg]

No hay comentarios:

Publicar un comentario