Penghapus Array

#‎include‬ <iostream>
#include <conio.h>
using namespace std;
main()
{
int nilai [3]={1,2,3};
int n;
int hapus,m;
for (n=0; n♥; n++)
{
cout<< nilai [n]<<" ";
}
cout<< "\n masukan nilai yang akan dihapus";
cin>>hapus;
for (n=0; n♥; n++)
{
if(hapus==nilai[n])
{
for (m=1; m<2; m++)
{
nilai[m]=nilai [m+1];
}
}
}
cout<<"\n data yang baru";
for (n=0; n♥; n++)
{
cout<< nilai [n]<<" ";
}
getch();
}

Post a Comment

0 Comments