Menggunakan Program C++
#include <iostream>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char** argv) {
int a[20],n;
cout<<"Batas : ";
cin>>n;
for (int i=0;i<n;i++){
cout<<"Data : ";
cin>>a[i];
}
for (int i=0;i<n;i++){
if(a[i]==a[i+1])
cout<<a[i];
else if(a[i-1]==a[i])
cout<<"";
else if(a[i]==a[i+2])
cout<<a[i];
else if(a[i-2]==a[i])
cout<<"";
else if(a[i]==a[i+3])
cout<<a[i];
else if(a[i-3]==a[i])
cout<<"";
else if(a[i]==a[i+4])
cout<<a[i];
else if(a[i-4]==a[i])
cout<<"";
else if(a[i]==a[i+5])
cout<<a[i];
else if(a[i-5]==a[i])
cout<<"";
else
cout<<a[i];
}
/* for (int i=0;i<n;i++){
cout<<a[i]<<" ";
}*/
return 0;
}
Tampilan/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char** argv) {
int a[20],n;
cout<<"Batas : ";
cin>>n;
for (int i=0;i<n;i++){
cout<<"Data : ";
cin>>a[i];
}
for (int i=0;i<n;i++){
if(a[i]==a[i+1])
cout<<a[i];
else if(a[i-1]==a[i])
cout<<"";
else if(a[i]==a[i+2])
cout<<a[i];
else if(a[i-2]==a[i])
cout<<"";
else if(a[i]==a[i+3])
cout<<a[i];
else if(a[i-3]==a[i])
cout<<"";
else if(a[i]==a[i+4])
cout<<a[i];
else if(a[i-4]==a[i])
cout<<"";
else if(a[i]==a[i+5])
cout<<a[i];
else if(a[i-5]==a[i])
cout<<"";
else
cout<<a[i];
}
/* for (int i=0;i<n;i++){
cout<<a[i]<<" ";
}*/
return 0;
}
Untuk 4.1 dan 4.2 bisa dipelajari di:
keronskl.blogspot.com
Untuk 4.5 dan 4.6 bisa dipelajari di:
pengantarprogram.blogspot.com