Assalamu'alaikum sob , saya kembali akan share kepada kamu semua mengenai codingan untuk kamu yang akan praktikum alpro pertemuan ke 9 , berikut c++ nya ...
No.1
#include <iostream>
#include <conio.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
class array{
public:
void panggil();
private :
int i,j;
int a[5]={1,2,3,4,5};
int b[5]={1,2,3,4,5};
};
void array::panggil(){
cout<<"data array a : "<<endl<<endl;
for(i=0; i<=4; i++){
cout<<"a|"<<i<<"i|="<<a[i]<<endl;
}cout<<endl;
cout<<"data array b : "<<endl<<endl;
for(j=0; j<=4; j++){
cout<<"b|"<<j<<"j|="<<b[j]<<endl;
}cout<<endl;
cout<<"array c: "<<endl;
for(i=0; i<=4; i++){
cout<<"| "<<a[i]<<" "<<b[i]<<" |"<<endl;
}
}
int main(){
array x;
x.panggil();
}
Output:
No.2
#include <iostream>
#include <string>
#include<conio.h>
using namespace std;
class Array{
public :
void buble (int bil[100], int N);
void pindah (int bil[100]);
};
void Array::buble (int bil[100], int N)
{
int n;
int temp;
int i;
int j;
//int[] bil = new int[int+1];
i =1;
while (!(i>N))
{
j =i+1;
while (!(j>N))
{
if (bil[i]>bil[j])
{
temp =bil[i];
bil[i] = bil[j];
bil[j] = temp;
}
else
{
}
j =j+1;
}
i =i+1;
}
cout << "Sorting " << endl; i =1;
while (!(i>N))
{
cout << bil[i] << endl; i =i+1;
}
}
void Array::pindah (int bil[100]){
string raptor_prompt_variable_zzyz;
int m;
int n;
int i;
int j;
int k;
int y[100][100];
j =1;
i =1;
raptor_prompt_variable_zzyz ="Banyak baris : ";
cout << raptor_prompt_variable_zzyz;
cin >> n;
raptor_prompt_variable_zzyz ="Banyak kolom : ";
cout << raptor_prompt_variable_zzyz;
cin >> m;
y[i][j] = 0;
k =1;
while (1)
{
j =1;
if ((i>n)) break;
while (!(j>m))
{
y[i][j] = bil[k];
k =k+1;
j =j+1;
}
i =i+1;
}
cout << "Data 2 Dimensi " << endl; i =1;
while (1)
{
j =1;
if ((i>n)) break;
while (!(j>m))
{
cout << y[i][j]; j =j+1;
}
cout << endl;
i =i+1;
}
}
int main()
{
Array x;
string raptor_prompt_variable_zzyz;
int N;
int i;
int bil[100];
raptor_prompt_variable_zzyz ="Banyak array : ";
cout << raptor_prompt_variable_zzyz;
cin >> N;
i =1;
while (!(i>N))
{
raptor_prompt_variable_zzyz ="input data : ";
cout << raptor_prompt_variable_zzyz;
cin >> bil[i];
i =i+1;
}
x.buble(bil,N);
x.pindah(bil);
cout<<endl;
getch();
return 0;
}
Output:
10 Aplikasi Android Yang Bikin Boros Baterai Smartphone
0 komentar:
Post a Comment