#include <cstdlib> |
#include <iostream> |
using namespace std; |
class matrik { |
public : |
void baca1(); |
void baca2(); |
void tulis1(); |
void tulis2(); |
void hitung(); |
double data1[2]; |
double data2[2]; |
private : |
double a,i; |
}; |
void matrik::baca1 (){ |
for(int a=1;a<=2;a++){ |
cout<<"Masukkan "<<a<< " : "; |
cin>>data1[a];} |
} |
void matrik::baca2 (){ |
for(int i=1;i<=2;i++) |
{ |
cout<<"Masukkan "<<i<<" : "; |
cin>>data2[i];} |
} |
void matrik::tulis1 (){ |
for(int a=1;a<=2;a++){ |
cout<<" "<<data1[a]; |
cout<<endl;} |
} |
void matrik::tulis2 (){ |
for(int i=1;i<=2;i++){ |
cout<<" "<<data2[i]; |
cout<<endl;} |
} |
void matrik::hitung (){ |
cout<<" "<<(data1[1]+data2[1])/2<<" "<<(data1[2]+data2[2])/2<<endl; |
} |
int main(int argc, char *argv[]) |
{ |
matrik a; |
cout<<"Masukkan data matriks 1 "<<endl; |
a.baca1(); |
cout<<"Masukkan data matriks 2 "<<endl; |
a.baca2(); |
cout<<"Data matriks 1 adalah : "<<endl; |
a.tulis1(); |
cout<<"Data matriks 2 adalah : "<<endl; |
a.tulis2(); |
cout<<"Titik tengah : "<<endl; |
a.hitung(); |
system("PAUSE"); |
return EXIT_SUCCESS; |
} |
Senin, 21 Maret 2011
TITIK TENGAH DARI DUA TITIK
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar