This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Tampilkan postingan dengan label how to solve. Tampilkan semua postingan
Tampilkan postingan dengan label how to solve. Tampilkan semua postingan

Minggu, 17 April 2016

how to solve 4.6

c++ :
#include<iostream>
#include<conio.h>
using namespace std;
main()
{
int data[10] = {4, 1, 0, -9, 8, 5, -1, 2, 3, -7};
int elemen, ketemu,x;
cout <<"Data yang dicari : ";cin >> x;
ketemu = 0;


for(elemen=0; elemen<= 9; elemen++)
{
if (data[elemen] == x)
{ ketemu =!ketemu;
break;
}
}
if (ketemu == 0) cout << "Data tidak ditemukan ";
else cout << "Data ada di elemen : "<< elemen;

getch();
}

SUBPROGRAM :
#include <iostream>
#include <conio.h>
using namespace std;
void coba(int elemen,int ketemu){
int data[10]={4, 1, 0, -9, 8, 5, -1, 2, 3, -7};
int x;
for(elemen=0; elemen<= 9; elemen++){
ketemu = 0;
{
if (data[elemen] == x)
{ ketemu =!ketemu;
}
}
}
if (ketemu == 0){
cout << "Data tidak ditemukan ";}
else {
cout << "Data ada di elemen : "<< elemen;}

}
main(){
int data[10]={4, 1, 0, -9, 8, 5, -1, 2, 3, -7};
int x,elemen,ketemu;
cout <<"Data yang dicari : ";cin >> x;
coba(elemen,ketemu);
getch();
}

how to solve 4.5

c++ :
#include <iostream>
using namespace std;

void quicksort(int *arr, int kiri, int kanan){
int tmp,i=kiri,j=kanan,cetak;
int pivot=arr[(kiri+kanan)/2];

while(i<=j){
while (arr[i]<pivot){
i++;
}
while (arr[j]>pivot){
j--;
}
if(i<=j){
tmp=arr[i];
arr[i]=arr[j];
arr[j]=tmp;
i++;
j--;
}
}
if(kiri<j)
quicksort(arr,kiri,j);
if(i<kanan)
quicksort(arr,i,kanan);
}
int main(){
int data[8]={17,10,13,15,18,12,14,16};
cout<<"awal : "<<data[8];
quicksort(data,0,7);
cout<<"terurut : "<<data[8];
return 0;
}

how to solve 4.4

#include <iostream>
#include <conio.h>
#include <stdio.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
int a[20], i, j, k ,n;
cout<<" enter aray size : ";
cin>>n;
cout<<" enter aray "<<n<<" elemen : \n";
for(i=0;i<n;i++){
cin>>a[i];
}

cout<<" new aray elemen are : ";
for(i=0;i<n;i++){
for(j=i+1;j<n;){
if(a[j]==a[i]){
for(k=j;k<n;k++){
a[k]=a[k+1];
}
n--;
}
else{
j++;
}
}
}
for(i=0;i<n;i++){
cout<<a[i]<<" ";
}

}




SUBPROGRAM :
#include <iostream>
#include <conio.h>
#include <stdio.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
void masuk(int a[20]){
int i,n,j,k;
for(i=0;i<n;i++){
 cin>>a[i];
 }

cout<<" new aray elemen are : ";
for(i=0;i<n;i++){
 for(j=i+1;j<n;){
  if(a[j]==a[i]){
   for(k=j;k<n;k++){
    a[k]=a[k+1];
   }
   n--;
  }
  else{
   j++;
  }
 }
}
for(i=0;i<n;i++){
 cout<<a[i]<<" ";
}

}
int main(int argc, char** argv) {
int a[20], i, j, k ,n;
cout<<" enter aray size : ";
cin>>n;
cout<<" enter aray "<<n<<" elemen : \n";
masuk(a);
}

how to solve 4.3

c++ :
#include <iostream>
#include <conio.h>
using namespace std;
main()
{
    int nilai[3],a,min,maks;
 cout<<"masukan berapa nilai yang mw di masukan : ";
 cin>>min;
    for(a=1;a<=min;a++){
   cout<<"Masukkan nilai ke-"<<a<<":";
   cin>>nilai[a];
    }
   maks = nilai[1];
   for(a=1;a<=min;a++){
    if(nilai[a] > maks){
   maks = nilai[a];
}
   }
   cout<<"nilai maksimum adalah : "<<maks<<endl;

getch();
return 0;
}




SUBPROGRAM :
#include <iostream>
#include <conio.h>
using namespace std;
void coba_lagi(int nilai[3],int a,int min,int maks){
   for(a=1;a<=min;a++){
   cout<<"Masukkan nilai ke-"<<a<<":";
   cin>>nilai[a];
    }
   maks = nilai[1];
   for(a=1;a<=min;a++){
    if(nilai[a] > maks){
   maks = nilai[a];
}
   }
   cout<<"nilai maksimum adalah : "<<maks<<endl;


}

main()
{
    int nilai[3],a,min,maks;
 cout<<"masukan berapa nilai yang mw di masukan : ";
 cin>>min;
coba_lagi(nilai,a,min,maks);
getch();
return 0;
}

how to solve no.1

c++ :
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
int m,n,c,d,first[10][10],second[10][10],sum[10][10];
cout<<" masukan baris dan colom : \n";
cin>>m>>n;
cout<<"masukan angka : \n";
for(c=0;c<m;c++){
for(d=0;d<n;d++){
cin>>first[c][d];
}
cout<<endl;
}
cout<<" balikannya : \n";
for(c=0;c<m;c++){
for(d=0;d<n;d++){
cout<<first[d][c];
}
cout<<endl;
}

for(c=0;c<m;c++){
for(d=0;d<n;d++){
sum[c][d]=first[c][d]+first[d][c];
}
}
cout<<"jumlah\n";
for(c=0;c<m;c++){
for(d=0;d<n;d++){
cout<<sum[c][d]<<"\t";
cout<<endl;
}
}

return 0;
}


SUBPROGRAM  : 
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

void masuk_keluar(int first[10][10],int second[10][10],int sum[10][10]){
int m,n,c,d;
for(c=0;c<m;c++){
for(d=0;d<n;d++){
cin>>first[c][d];
}
cout<<endl;
}
cout<<" balikannya : \n";
for(c=0;c<m;c++){
for(d=0;d<n;d++){
cout<<first[d][c];
}
cout<<endl;
}

for(c=0;c<m;c++){
for(d=0;d<n;d++){
sum[c][d]=first[c][d]+first[d][c];
}
}
cout<<"jumlah\n";
for(c=0;c<m;c++){
for(d=0;d<n;d++){
cout<<sum[c][d]<<"\t";
cout<<endl;
}
}
}



int main(int argc, char** argv) {
int m,n,c,d,first[10][10],second[10][10],sum[10][10];
cout<<" masukan baris dan colom : \n";
cin>>m>>n;
cout<<"masukan angka : \n";
masuk_keluar(first,second,sum);

 return 0;
}