#include <cstdlib>
#include <iostream>
#define maks10
using namespace std;
class array{
friend ostream& operator<<(ostream&, const array&);
friend istream& operator>>(istream&, array&);
public:
//array();
void cetak();
void geser_kiri();
private:
int z;
char a[5];
int posisi;
};
/*array::array(){
cin>>z;
}
void array::cetak(){
for(int i=0;i<z;i++)
cout<<a[i]<<" ";
}*/
istream& operator>>(istream& in, array& masuk){
int posisi,z;
for (int posisi=1; posisi<=5; posisi++){
cout<<"masukkan nilai array posisi ke-"<<posisi<<"= ";
if(posisi >= 0 && posisi <= 5){
in>>masuk.a[posisi-1];
}
}
return in;
}
ostream& operator<<(ostream& out, const array& keluar){
int z;
for(int i=0;i<5;i++)
out<<keluar.a[i]<<" ";
out<<endl;
return out;
}
void array::geser_kiri(){
int n=5;
int temp=a[0];
for(int i=0;i<n;i++)
a[i]=a[i+1];
a[n-1]=temp;
}
int main(){
array X;
cin>>X;
cout<<"Isi Array saat ini : "<<X;
X.geser_kiri();
cout<<"Isi Array setelah di geser kiri : "<<X;
system("PAUSE");
return EXIT_SUCCESS;
}
Tidak ada komentar:
Posting Komentar