Sei sulla pagina 1di 6

using using using using

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

namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int f, nf, c, nc; int x = 3, y = 3; Console.Write("ingrese el nuemero de filas "); nf = int.Parse(Console.ReadLine()); Console.Write("ingrese el nuemero de colunnas "); nc = int.Parse(Console.ReadLine()); int[,] matriz = new int[nf, nc]; for (f = 0; f < nf; f++) { for (c = 0; c < nc; c++) { Console.SetCursorPosition(x, y); matriz[f, c] = int.Parse(Console.ReadLine()); x = x + 3; } x = 3; y = y + 3; } for (f = 0; f < nf; f++) { for (c = 0; c < nc; c++) { Console.SetCursorPosition(x, y); if (f == c) { matriz[f, c] = 0; Console.WriteLine("{0}", matriz[f, c]); } else { matriz[f, c] = 1; Console.WriteLine("{0}", matriz[f, c]); } x = x + 3; } x = 3; y = y + 3; }

Console.ReadLine(); } } } :::::::::::::::::::::::::::::::::::::::::: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int f, nf, c, nc; int x = 3, y = 3; Console.Write("ingrese el nuemero de filas "); nf = int.Parse(Console.ReadLine()); Console.Write("ingrese el nuemero de colunnas "); nc = int.Parse(Console.ReadLine()); int[,] matriz = new int[nf, nc]; for (f = 0; f < nf; f++) { for (c = 0; c < nc; c++) { Console.SetCursorPosition(x, y); matriz[f, c] = int.Parse(Console.ReadLine()); x = x + 3; } x = 3; y = y + 3; } for (f = 0; f < nf; f++) { for (c = 0; c < nc; c++) { Console.SetCursorPosition(x, y); if (f %2 ==0) { matriz[f, c] = 0; Console.WriteLine("{0}", matriz[f, c]); } else { matriz[f, c] = 1; Console.WriteLine("{0}", matriz[f, c]); } x = x + 3;

} x = 3; y = y + 3; }

Console.ReadLine(); } } } ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]] using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int f, nf, c, nc; int x = 3, y = 3; Console.Write("ingrese el nuemero de filas "); nf = int.Parse(Console.ReadLine()); Console.Write("ingrese el nuemero de colunnas "); nc = int.Parse(Console.ReadLine()); int[,] matriz = new int[nf, nc]; for (f = 0; f < nf; f++) { for (c = 0; c < nc; c++) { Console.SetCursorPosition(x, y); matriz[f, c] = int.Parse(Console.ReadLine()); x = x + 3; } x = 3; y = y + 3; } Console.Write("inserte el nuero que quiere busacar"); int bus = int.Parse(Console.ReadLine()); for (f = 0; f < nf; f++) { for (c = 0; c < nc; c++) {

if (matriz[f, c] == bus) { Console.WriteLine("el valor [{0}] esta en la fila: [{1}] ", bus, f, c); }

, colucna: [{2}]

Console.ReadLine(); } } } ::::::::::::::::::::::::::::::::::::::::::::::: multiplicacion using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int nfa, fa, nca, ca, x = 3, y = 3; int nfb, fb, ncb, cb, h = 16, d = 3; int nfr = 0, fr, ncr = 0, cr, i = 8, o = 7; int[,] matrizA; int[,] matrizB; int[,] matrizR; Console.WriteLine("Matriz >>A<< "); Console.WriteLine("ingrese filas"); nfa = int.Parse(Console.ReadLine()); Console.WriteLine("ingrese columnas"); nca = int.Parse(Console.ReadLine()); Console.WriteLine("Matriz >>B<< "); Console.WriteLine("ingrese filas"); nfb = int.Parse(Console.ReadLine()); Console.WriteLine("ingrese columnas"); ncb = int.Parse(Console.ReadLine()); if (nca == nfb) {

nfr = nfa; ncr = ncb; matrizA = new int[nfa, nca]; matrizB = new int[nfb, ncb]; matrizR = new int[nfr, ncr]; Console.Clear(); for (fa = 0; fa < nfa; fa++) { for (ca = 0; ca < nca; ca++) { Console.SetCursorPosition(x, y); matrizA[fa, ca] = int.Parse(Console.ReadLine()); x = x + 2; } x = 3; y = y + 2; }

for (fb = 0; fb < nfb; fb++) { for (cb = 0; cb < ncb; cb++) { Console.SetCursorPosition(h, d); matrizB[fb, cb] = int.Parse(Console.ReadLine()); h = h + 2; } h = 16; d = d + 2; } Console.Clear(); Console.WriteLine("la muntiplicacion de A*b es posible "); Console.WriteLine("esta matris queda [{0}]*[{1}]<>[{2}]*[{3}] ", nfa, nca, nfb, ncb); Console.WriteLine("el orden de esta matriz es [{0}]*[{1}] ", nfa , ncb);

for (fr = 0; fr < nfr; fr++) { for (cr = 0; cr < ncr; cr++) { for (fb = 0; fb < nfb; fb++) { matrizR[fr, cr] = (matrizR[fr, cr]+(matrizA[fr, fb] * matrizB[fb, cr])); }

Console.SetCursorPosition(i, o); Console.WriteLine(" {0} ", matrizR[fr, cr]); i = i + 2; } i = 8; o = o + 2; } } else { Console.WriteLine("la muntiplicacion de A*b no se puede realizar "); } Console.ReadLine(); } } }

Potrebbero piacerti anche