#include <iostream.h>
void input(int A[],int n){
for(int x=0;x<n;x++){
cout<<"Masukkan Nilai ="<<x<<" = ";
cin>>A[x];
}
}
void tukar(int A[], int B[], int n){
for(int x=0;x<n;x++){
A[x]=A[x]+B[x];
B[x]=A[x]-B[x];
A[x]=A[x]-B[x];
}
}
void output(int A[], int n){
for(int x=0;x<n;x++){
cout<<"Hasil Tukar = "<<x<<" = "<<A[x]<<endl;
}
}
int main() {
int A[5], B[5];
input(A,5);
cout<<endl;
input(B,5);
cout<<endl;
tukar(A,B,5);
cout<<endl;
output(A,5);
cout<<endl;
cout<<endl;
output(B,5);
return 0;
}
void input(int A[],int n){
for(int x=0;x<n;x++){
cout<<"Masukkan Nilai ="<<x<<" = ";
cin>>A[x];
}
}
void tukar(int A[], int B[], int n){
for(int x=0;x<n;x++){
A[x]=A[x]+B[x];
B[x]=A[x]-B[x];
A[x]=A[x]-B[x];
}
}
void output(int A[], int n){
for(int x=0;x<n;x++){
cout<<"Hasil Tukar = "<<x<<" = "<<A[x]<<endl;
}
}
int main() {
int A[5], B[5];
input(A,5);
cout<<endl;
input(B,5);
cout<<endl;
tukar(A,B,5);
cout<<endl;
output(A,5);
cout<<endl;
cout<<endl;
output(B,5);
return 0;
}
Tidak ada komentar:
Posting Komentar