Çok boyutlu dizilerde örnek (matris toplamı)
#include <stdio.h>
#include <conio.h>
main()
{
int m1[4][4]={{10,12,14,18},{20,14,16,13},{25,14,41,21},{32,36,41,57}};
int m2[4][4]={{40,30,20,10},{7,9,8,6},{21,22,23,24},{34,35,36,37}};
int toplam[4][4];
//satırları okuyacak
for(int i=0;i<4;i++)
{
for(int j=0;j<4;j++)
{
toplam[i][j]=m1[i][j]+m2[i][j];
}
}
for(int i=0;i<4;i++)
{
for(int j=0;j<4;j++)
{
printf(" %d ",toplam[i][j]);
}
printf("\n");
}
getch();
}
#include <conio.h>
main()
{
int m1[4][4]={{10,12,14,18},{20,14,16,13},{25,14,41,21},{32,36,41,57}};
int m2[4][4]={{40,30,20,10},{7,9,8,6},{21,22,23,24},{34,35,36,37}};
int toplam[4][4];
//satırları okuyacak
for(int i=0;i<4;i++)
{
for(int j=0;j<4;j++)
{
toplam[i][j]=m1[i][j]+m2[i][j];
}
}
for(int i=0;i<4;i++)
{
for(int j=0;j<4;j++)
{
printf(" %d ",toplam[i][j]);
}
printf("\n");
}
getch();
}
![]() |
| C de matris toplamı |

Yorumlar
Yorum Gönder