Kamis, 22 Oktober 2015
Program C++ 2 array 2 dimensi
#include<iostream>
#include<conio.h>
int main()
{
int matrix[2][2];
int i,j;
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
cout<<"Masukkan Nilai Angka Pada Baris Ke "<<i<<" dan Kolom Ke "<<j<<" : ";
cin>>matrix[i][j];
}
cout<<endl;
}
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
cout<<matrix[i][j]<<" ";
}
cout<<endl;
}
getch ();
}
Program c++ Penjumlahan Matrik Dan Prosesnya
Hellloo gengs,, udah lama banget nih gak corat coret :D .
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();
}
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?
Manajemen Proses -Linux Ubuntu-
Secara informal, proses adalah program dalam eksekusi. Suatu proses adalah lebih dari kode program, dimana kadang kala dikenal sebagai bagian tulisan. Proses juga termasuk aktivitas yang sedang terjadi, sebagaimana digambarkan oleh nilai pada program counter dan isi dari daftar prosesor/ processor’s register.
Langganan:
Postingan (Atom)