mari kita berkreasi (sok bangt, padahal cuma diajarin temen :v), ok langsung saja , nih gara-gara tugas semester 3 nih ane ngerjain nih coding , outputnya kerjain aja sendiri :p
#include <iostream.h>
#include <conio.h>
void main()
{
int matrix[2][2], matrix2[2][2],jumlah[2][2];
int i, j;
cout<<"matrix A :";
cout<<endl;
for (i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
cout<<"masukkan nilai baris"<<i+1<<" kolom "<<j+1<<" : ";
cin>>matrix[i][j];
}
}
cout<<"\nMatrix B :\n";
for (i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
cout<<"masukkan nilai baris"<<i+1<<" kolom "<<j+1<<" : ";
cin>>matrix2[i][j];
}
}
for (i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
jumlah[i][j]=matrix[i][j] + matrix2[i][j];
}
}
cout<<endl;
gotoxy(1,18);
cout<<"C = ";
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
gotoxy(5+4*j,17+2*i);
cout<<matrix[i][j];
}
}
gotoxy(13,18);
cout<<" + ";
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
gotoxy(18+4*j,17+2*i);
cout<<matrix2[i][j];
}
}
gotoxy(28,18);
cout<<" = ";
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
gotoxy(33+4*j,17+2*i);
cout<<jumlah[i][j];
}
}
getch();
}
Proses
“MATRIK C=MATRIK A +
MATRIK B”
MATRIK A
i=0
i<2 ? , 0<2 ? T
j=0
j<2 ? , 0<2
? T
cout<<"masukkan
nilai baris"<<i+1<<" kolom "<<j+1<<"
: "
cout<<"masukkan
nilai baris"<<0+1<<" kolom "<<0+1<<"
: "
input matrik[i][j]
input matrik[0][0]
j++
j+1=0+1=1
j=1
j<2 ? ,
1<2 ? T
cout<<"masukkan
nilai baris"<<i+1<<" kolom "<<j+1<<"
: "
cout<<"masukkan
nilai baris"<<0+1<<" kolom "<<1+1<<"
: "
input matrik[i][j]
input matrik[0][1]
j++
j+1=1+1=2
j=2
j<2 ? , 2<2
? F
i++
i++=i+1=1
i=1
i<2,1<2?T
j=0
j<2 ? ,
0<2 ? T
cout<<"masukkan
nilai baris"<<i+1<<" kolom "<<j+1<<"
: "
cout<<"masukkan
nilai baris"<<1+1<<" kolom "<<0+1<<"
: "
input matrik[i][j]
input matrik[1][0]
j++
j+1=0+1=1
j=1
j<2 ? ,
1<2 ? T
cout<<"masukkan
nilai baris"<<i+1<<" kolom "<<j+1<<"
: "
cout<<"masukkan
nilai baris"<<1+1<<" kolom "<<1+1<<"
: "
input matrik[i][j]
input matrik[1][1]
j++
j+1=1+1=2
j=2
j<2 ? ,
2<2 ? F
i++
i++=1+1=2
i=2
i<2,2<2?
F
MATRIK B
i=0
i<2
? , 0<2 ? T
j=0
j<2 ? ,
0<2 ? T
cout<<"masukkan
nilai baris"<<i+1<<" kolom "<<j+1<<"
: "
cout<<"masukkan
nilai baris"<<0+1<<" kolom "<<0+1<<"
: "
input matrik2[i][j]
input matrik2[0][0]
j++
j+1=0+1=1
j=1
j<2 ? ,
1<2 ? T
cout<<"masukkan
nilai baris"<<i+1<<" kolom "<<j+1<<"
: "
cout<<"masukkan
nilai baris"<<0+1<<" kolom "<<1+1<<"
: "
input matrik2[i][j]
input matrik2[0][1]
j++
j+1=1+1=2
j=2
j<2 ? ,
2<2 ? F
i++
i++=i+1=1
i=1
i<2,1<2?T
j=0
j<2 ? ,
0<2 ? T
cout<<"masukkan
nilai baris"<<i+1<<" kolom "<<j+1<<"
: "
cout<<"masukkan
nilai baris"<<1+1<<" kolom "<<0+1<<"
: "
input matrik2[i][j]
input matrik2[1][0]
j++
j+1=0+1=1
j=1
j<2 ? ,
1<2 ? T
cout<<"masukkan
nilai baris"<<i+1<<" kolom "<<j+1<<"
: "
cout<<"masukkan
nilai baris"<<1+1<<" kolom "<<1+1<<"
: "
input matrik2[i][j]
input matrik2[1][1]
j++
j+1=1+1=2
j=2
j<2 ? ,
2<2 ? F
i++
i++=1+1=2
i=2
i<2,2<2?
F
=====================================================================================
i=0
i<2
? , 0<2 ? T
j=0
j<2 ? ,
0<2 ? T
jumlah[i][j]=matrix[i][j]
+ matrix2[i][j];
jumlah[i][j]=matrix[0][0]
+ matrix2[0][0];
j++
j+1=0+1=1
j=1
j<2 ? ,
1<2 ? T
jumlah[i][j]=matrix[i][j]
+ matrix2[i][j];
jumlah[i][j]=matrix[0][1]
+ matrix2[0][1];
j++
j+1=1+1=2
j=2
j<2 ? ,
2<2 ? F
i++
i++=i+1=1
i=1
i<2,1<2?T
j=0
j<2 ? ,
0<2 ? T
jumlah[i][j]=matrix[i][j]
+ matrix2[i][j];
jumlah[i][j]=matrix[1][0]
+ matrix2[1][0];
j++
j+1=0+1=1
j=1
j<2 ? ,
1<2 ? T
jumlah[i][j]=matrix[i][j]
+ matrix2[i][j];
jumlah[i][j]=matrix[1][1]
+ matrix2[1][1];
j++
j+1=1+1=2
j=2
j<2 ? ,
2<2 ? F
i++
i++=1+1=2
i=2
i<2,2<2?
=====================================================================================
Tampilkan “C =matrik a+matrik b”
Sebelum “+”
i=0
i<2
? , 0<2 ? T
j=0
j<2 ? ,
0<2 ? T
cout<<"masukkan
nilai baris"<<i+1<<" kolom "<<j+1<<"
: "
cout<<"masukkan
nilai baris"<<0+1<<" kolom "<<0+1<<"
: "
output matrik[i][j]
output matrik[0][0]
j++
j+1=0+1=1
j=1
j<2 ? ,
1<2 ? T
cout<<"masukkan
nilai baris"<<i+1<<" kolom "<<j+1<<"
: "
cout<<"masukkan
nilai baris"<<0+1<<" kolom "<<1+1<<"
: "
output matrik[i][j]
output matrik[0][1]
j++
j+1=1+1=2
j=2
j<2 ? ,
2<2 ? F
i++
i++=i+1=1
i=1
i<2,1<2?T
j=0
j<2 ? ,
0<2 ? T
cout<<"masukkan
nilai baris"<<i+1<<" kolom "<<j+1<<"
: "
cout<<"masukkan
nilai baris"<<1+1<<" kolom "<<0+1<<"
: "
output matrik[i][j]
output matrik[1][0]
j++
j+1=0+1=1
j=1
j<2 ? ,
1<2 ? T
cout<<"masukkan
nilai baris"<<i+1<<" kolom "<<j+1<<"
: "
cout<<"masukkan
nilai baris"<<1+1<<" kolom "<<1+1<<"
: "
output matrik[i][j]
output matrik[1][1]
j++
j+1=1+1=2
j=2
j<2 ? ,
2<2 ? F
i++
i++=1+1=2
i=2
i<2,2<2?
F
=====================================================================================
Tampilan setelah “+”
i=0
i<2
? , 0<2 ? T
j=0
j<2 ? ,
0<2 ? T
cout<<"masukkan
nilai baris"<<i+1<<" kolom "<<j+1<<"
: "
cout<<"masukkan
nilai baris"<<0+1<<" kolom "<<0+1<<"
: "
output matrik2[i][j]
output matrik2[0][0]
j++
j+1=0+1=1
j=1
j<2 ? ,
1<2 ? T
cout<<"masukkan
nilai baris"<<i+1<<" kolom "<<j+1<<"
: "
cout<<"masukkan
nilai baris"<<0+1<<" kolom "<<1+1<<"
: "
output matrik2[i][j]
output matrik2[0][1]
j++
j+1=1+1=2
j=2
j<2 ? ,
2<2 ? F
i++
i++=i+1=1
i=1
i<2,1<2?T
j=0
j<2 ? ,
0<2 ? T
cout<<"masukkan
nilai baris"<<i+1<<" kolom "<<j+1<<"
: "
cout<<"masukkan
nilai baris"<<1+1<<" kolom "<<0+1<<"
: "
output matrik2[i][j]
output matrik2[1][0]
j++
j+1=0+1=1
j=1
j<2 ? ,
1<2 ? T
cout<<"masukkan
nilai baris"<<i+1<<" kolom "<<j+1<<"
: "
cout<<"masukkan
nilai baris"<<1+1<<" kolom "<<1+1<<"
: "
output matrik2[i][j]
output matrik2[1][1]
j++
j+1=1+1=2
j=2
j<2 ? ,
2<2 ? F
i++
i++=1+1=2
i=2
i<2,2<2?
F
Tampilan setelah “ =”
i=0
i<2
? , 0<2 ? T
j=0
j<2 ? ,
0<2 ? T
jumlah[i][j]=
j++
j+1=0+1=1
j=1
j<2 ? ,
1<2 ? T
jumlah[i][j]=
j++
j+1=1+1=2
j=2
j<2 ? ,
2<2 ? F
i++
i++=i+1=1
i=1
i<2,1<2?T
j=0
j<2 ? ,
0<2 ? T
jumlah[i][j]=
j++
j+1=0+1=1
j=1
j<2 ? ,
1<2 ? T
jumlah[i][j]=
j++
j+1=1+1=2
j=2
j<2 ? ,
2<2 ? F
i++
i++=1+1=2
i=2
i<2,2<2?
Lucky 15 Casino & Hotel - Mapyro
BalasHapusFind the 김천 출장마사지 best prices on Lucky 15 Casino 용인 출장마사지 & Hotel in Lain County, India. Lucky 15 Casino & Hotel is located 제주도 출장안마 near 통영 출장마사지 Lake Geneva, Illinois near Lake Havasu. Rating: 8.1/10 · 화성 출장샵 34 reviews · Price range: $