1. Array [Input & Output]
#include <iostream>
using namespace std;
class Arrq{
private:
int arr[9];
int i;
public:
void input(int i,int b){
if (i<b){
cout<<"Masukkan Array ";
cin>>arr[i];
input(i+1,b);
}
}
void output(int i,int b){
//for (int i=0;i<9;i++){
if (i<b){
cout<<arr[i]<<" ";
cout<<endl;
output(i+1,b);
}
}
};
int main(int argc, char *argv[]) {
Arrq a;
a.input(0,9);
cout<<endl;
a.output(0,9);
return 0;
}
2. Array [Mengubah baris menjadi kolom]
#include <iostream>
using namespace std;
int main(int argc, char *argv[]) {
int arr[9]={1,2,3,4,5,6,7,8,9,};
int p=0;
cout<<"sebelum di tukar= \n";
for(int b=0;b<3;b++){
for(int h=0;h<3;h++){
cout<<arr[h+p]<<" ";
}cout<<endl;
p=p+3;
}
int q=0;
for (int c=0;c<9;c++){
if (arr [c]%3!=0){
int temp=arr[c];
arr[c]=arr[c+1];
arr[c+1]=temp;
}
}
cout<<"setelah di tukar = \n";
cout<<endl;
for(int i=0;i<3;i++){
for (int a=0;a<3;a++){
cout<<arr[a+q]<<" ";
}cout<<endl;
q=q+3;
}
return 0;
}
Subscribe to:
Post Comments (Atom)
R-chord 謝和弦 - I'm Not Your Prince Charming 我不是白馬王子 Lyrics 歌詞 with Pinyin
R-chord 謝和弦 x 高爾宣 & 李傑明 - I'm Not Your Prince Charming 我不是白馬王子 (Wo Bu Shi Bai Ma Wang Zi) Lyrics 歌詞 with Pinyin | 謝和弦 我不是白馬王子 歌詞 ...
-
Candi Ijo adalah sebuah kompleks percandian bercorak Hindu, berada 4 kilometer arah tenggara dari Candi Ratu Boko atau kita-kira 18 ki...
-
Ngobaran beach is located approximately two kilometers from Ngrenehan beach. At this beach you can see temples, statues, and the beautiful b...
-
South Korean girlband star, Twice confirmed a tour and concert schedule in 2018. As part of their Twice 2nd Tour: Twiceland Zone 2 - Fantasy...
No comments:
Post a Comment