ini buat yg masih bingung bagaimana cara edit data pada array 2 dimensi...yuuuk mari kita simak !!!!!!
#include <iostream>
#include <conio>
int main(){
typedef int matrik[100][100];
matrik a;
int b,c,x,y,d,e,f;
cout<<"\n masukkan kolom =";cin>>d;
cout<<"\n masukkan baris =";cin>>e;
for(x=0;x<d;x++)
{
for(y=0;y<e;y++)
{
cout<<"\nmatrik
a["<<x<<"]["<<y<<"]=";
cin>>a[x][y];}
}cout<<endl;
cout<<"======================================"<<endl;
cout<<"masukkan data yg akan di edit =\n";
cin>>f;
for(x=0;x<d;x++)
{
for(y=0;y<e;y++)
{
if(a[x][y]==f)
{cout<<"\n masukkan data yg baru =";
cin>>c;
a[x][y]=c;
}
}
}
cout<<"\n matrik yg baru =\n";
for(x=0;x<d;x++)
{
for(y=0;y<e;y++)
{cout<<a[x][y]<<"\t";
}
cout<<"\n";
}
getch(); }
0 komentar:
Posting Komentar