#include<stdio.h>
void printArray(int[][3]);
main()
{
int matrik1[2][3]={{1,2,3},{4,5,6}};
int matrik2[2][3]={{1,2,3},{4,5}};
int matrik3[2][3]={{1,2},{4}};
printArray(matrik1);
printArray(matrik2);
printArray(matrik3);
return 0;
}
void printArray(int a[][3])
{ int i,j;
for(i=0;i<=1;i++)
{ for(j=0;j<=2;j++)
printf("%d",a[i][j]);
printf("\n");
}
}
//program penjumlahan matrik
#include<iostream.h>
main()
{
int A[3][2]={{1,2},{3,4},{5,6}};
int B[3][2]={{7,8},{9,10},{11,12}};
int C[3][2];
int i,j;
cout<<"Matrik A=\n";
for(i=0;i<3;i++)
{
for(j=0;j<2;j++)
cout<<A[i][j]<<" ";
cout<<endl;
}
cout<<"Matrik B=\n";
for(i=0;i<3;i++)
{
for(j=0;j<2;j++)
cout<<B[i][j]<<" ";
cout<<endl;
}
//penjumlahan matrik
for(i=0;i<3;i++)
for(j=0;j<2;j++)
C[i][j]=A[i][j]+B[i][j];
cout<<"Matrik C=\n";
for(i=0;i<3;i++)
{
for(j=0;j<2;j++)
cout<<C[i][j]<<" ";
cout<<endl;
}
}
Sabtu, 30 Maret 2013
Langganan:
Posting Komentar (Atom)
0 komentar:
Posting Komentar