Friday, May 6, 2016

4. Program Vector C++ #TK (Diktat)

Tags

Algoritma Pemrograman

Diktat Bab 7 No. 4
Program Vector C++

#include <iostream>
#include <windows.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
void masuk(int c[20],int b[20]){
for (int i=1;i<=2;i++){
for (int j=1;j<=3;j++){
cout<<"Vaktor A "<<i<<","<<j<<" =";cin>>b[i,j];
cout<<"Vaktor B "<<i<<","<<j<<" =";cin>>c[i,j];

}
}
system("cls");
}
void proses(int b[20],int c[20],int hasil[20],int kali[20]){

cout<<"Vaktor A"<<endl;
for(int i=1;i<=2;i++){
for(int j=1;j<=3;j++){
cout<<b[i,j]<<" ";
}
}
cout<<"\n\nVaktor B"<<endl;
for(int i=1;i<=2;i++){
for(int j=1;j<=3;j++){
cout<<c[i,j]<<" ";
}
}
cout<<"\n\nVektor C"<<endl;
for (int i=1;i<=2;i++){
for (int j=1;j<=3;j++){
hasil[i,j]=b[i,j]+c[i,j];

cout<<hasil[i,j]<<" ";
}

}
cout<<"\n\nVaktor Hasil Kali"<<endl;
for (int i=1;i<=2;i++){
for (int j=1;j<=3;j++){
kali[i,j]=b[i,j]*hasil[i,j];

cout<<kali[i,j]<<" ";
}

}
cout<<"\n\nBanyak Elemen ="<<12;
}

int main(int argc, char** argv) {
int hasil[20];
int kali[20];
int b[20];
int c[20];
cout<<"Menghitung faktor"<<endl;
masuk(b,c);
proses(b,c,hasil,kali);
return 0;
}



EmoticonEmoticon