Rabu, 28 Desember 2011

C++ | contoh soal array

/*
mis nilai random array 4x5
nilai A
a b c d e
f  g h  i  j
k l m n o
p q r s t



hasil nilai
e d c b a
j  i  h g f
o n m l k
t  s r q p
*/

#include<iostream>
using namespace std;

int main(){
int A[4][5];
for(int i=0;i<4;i++){
for(int j=0;j<5;j++){
A[i][j]=rand()%20-10;//random nilai
cout <<A[i][j]<<"\t";
}
cout <<endl;//cetak enter
}
cout <<endl;
for(int i=0;i<4;i++){
for(int j=4;j>=0;j--){
cout <<A[i][j]<<"\t";
}
cout <<endl;
}
return 0;
}

hasilnya

terima kasih
Categories:

0 komentar :

Poskan Komentar