1 / 7

STRUKTUR DATA

STRUKTUR DATA. ARRAY BERDIMENSI 2. ARRAY DIMENSI 2. Array dimensi dua tersusun dalam bentuk baris dan kolom , dimana indeks pertama menunjukan baris dan indeks kedua menunjukan kolom . Array dimensi dua dapat digunakan seperti pendataan penjualan , nilai , dll. DEKLARASI.

Télécharger la présentation

STRUKTUR DATA

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. STRUKTUR DATA ARRAY BERDIMENSI 2

  2. ARRAY DIMENSI 2 • Array dimensiduatersusundalambentukbarisdankolom, dimanaindekspertamamenunjukanbarisdanindekskeduamenunjukankolom. • Array dimensiduadapatdigunakansepertipendataanpenjualan, nilai, dll.

  3. DEKLARASI • Bentukumumpendeklarasian array tipe_datanama_larik [indeks_1][indeks_2] keterangan : • tipe_data : untukmenyatakantipe data yang digunakan • Nama_larik : untukmenyatakannama array • Indeks_1 : untukmenyatakanjumlahbaris • Indeks_2 : untukmenyatakanjumlahkolom • Contohpendeklarasian Array data penjualanpertahun

  4. Dari tabeldiatasdapatdituliskankedalam array dimensiduasebagaiberikut: intdata_jual[3][3]; Jumlahkolom Jumlahbaris Nama array Tipe data elemen array

  5. #include<conio.h> #include<stdio.h> #include<iostream.h> #include<iomanip.h> void main() { inti,j; intdata_jual[3][3]; clrscr(); for(i=0; i<3; i++) { for(j=0; j<3; j++) { cout<<"data ke- "<<i<<" "<<j<<endl; cout<<"jumlahpenjualan : "; cin>>data_jual[i][j]; } } cout<<"Data PenjualanPertahun\n"; cout<<"-----------------------\n"; cout<<"NO 2001 2002 2003\n"; cout<<"-----------------------\n"; for(i=0; i<3; i++) { cout<<setiosflags(ios::left)<<setw(4)<<i; for(j=0; j<3; j++) { cout<<setiosflags(ios::right)<<setw(4); cout<<data_jual[i][j]; cout<<" "; } cout<<endl; } cout<<"-----------------------\n"; getch(); }

  6. latihan

More Related