Notes
Notes - notes.io |
int i, j;
Console.WriteLine("------ Birinici Matris ------");
Console.WriteLine(" ");
Console.Write("Kaç satır olacak : ");
int satir = Convert.ToInt32(Console.ReadLine());
Console.Write("Kaç sütun olacak : ");
int sutun = Convert.ToInt32(Console.ReadLine());
int[,] matrisA = new int[satir, sutun];
for (i = 0; i < satir; i++)
{
for (j = 0; j < sutun; j++)
{
Console.Write("{0}X{1} elemanı giriniz : ", i + 1, j + 1);
matrisA[i, j] = Convert.ToInt32(Console.ReadLine());
}
}
//----------------------------------------------------------------
Console.WriteLine("------ İkinci Matris ------");
Console.WriteLine(" ");
int[,] matrisB= new int[satir,sutun];
for (i = 0; i < satir; i++)
{
for (j = 0; j < sutun; j++)
{
Console.Write("{0}X{1} elemanı giriniz : ", i + 1, j + 1);
matrisB[i, j] = Convert.ToInt32(Console.ReadLine());
}
}
//----------------------------------------------------------------
//Toplma
Console.WriteLine("");
int[,] matrisC = new int[satir, sutun];
for (i = 0; i < satir; i++)
{
for (j = 0; j < sutun; j++)
{
matrisC[i, j] = matrisA[i, j] + matrisB[i, j];
}
}
for (i = 0; i < satir; i++)
{
for (j = 0; j < sutun; j++)
{
Console.Write(" {0} ", matrisC[i, j]);
}
Console.WriteLine("n");
Console.ReadKey();
}
//----------------------------------------------------------------
}
}
}
Örnek 2:2 Matrisi çarpma
int sA, sB;
Console.WriteLine("Çarpacağınız Matrislerin Boyutlarını Giriniz: ");
sA = Convert.ToInt32(Console.ReadLine());
sB = Convert.ToInt32(Console.ReadLine());
int[,] Fmatris=new int[sA,sB]; //First Matris
int[,] Smatris = new int[sB, sA]; //Second Matris
int[,] Sonuc=new int[sA,sA];
Console.WriteLine("<-- First Matris -->");
for(int i=0;i<sA;i++)
{
for(int k=0;k<sB;k++)
{
Console.Write(i + ". Satırın " + k + ". Elemanı: " );
Fmatris[i, k] = Convert.ToInt32(Console.ReadLine());
}
}
Console.WriteLine("<-- Second Matris -->");
for (int i = 0; i < sB; i++)
{
for (int k = 0; k < sA; k++)
{
Console.Write(i + ". Satırın " + k + ". Elemanı: ");
Smatris[i, k] = Convert.ToInt32(Console.ReadLine());
}
}
Console.WriteLine("<---1. matris--->");
for(int i=0;i<sA;i++)
{
for(int k=0;k<sB;k++)
{
Console.Write(Fmatris[i,k]);
Console.Write(" ");
}
Console.WriteLine();
}
Console.WriteLine("<---2. matris--->");
for (int i = 0; i < sB; i++)
{
for (int k = 0; k < sA; k++)
{
Console.Write(Smatris[i, k]);
Console.Write(" ");
}
Console.WriteLine();
}
//Çarpma İşlemini Yapıyoruz.
for (int i = 0; i < sA; i++)
{
for (int k = 0; k < sA; k++)
{
for (int j = 0; j < sB; j++)
{
Sonuc[i,k] += Fmatris[i,j] * Smatris[j,k];
}
}
}
Console.WriteLine("<---Matrislerin Çarpımlarının Sonucu--->");
for(int i=0;i<sA;i++)
{
for(int k=0;k<sA;k++)
{
Console.Write(Sonuc[i,k]);
Console.Write(" ");
}
Console.WriteLine();
}
Console.ReadKey();
}
}
}
Örnek 3:Tranpoze
Console.Write("Kare matris için geçerlidir.nMatris boyutunu giriniz:");
int boyut = Convert.ToInt32(Console.ReadLine());
Random rnd = new Random();
int[,] matrisA = new int[boyut, boyut];
// Matris oluşturma ve listeleme
for (int i = 0; i < boyut; i++)
{
for (int j = 0; j < boyut; j++)
{
matrisA[i, j] = rnd.Next(1, 25);
Console.Write(matrisA[i, j] + "t");
}
Console.WriteLine();
}
Console.WriteLine();
// Matrisin transpozunu alma
for (int i = 0; i < boyut; i++)
{
for (int j = i; j < boyut; j++)
{
int gecici = matrisA[i, j];
matrisA[i, j] = matrisA[j, i];
matrisA[j, i] = gecici;
}
}
for (int i = 0; i < boyut; i++)
{
for (int j = 0; j < boyut; j++)
Console.Write(matrisA[i, j] + "t");
Console.WriteLine();
}
Console.Read();
}
}
}
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team