Posts

Showing posts from January, 2024

Jawaban Algoritma Pemrograman

 Soal No 1 #include <iostream> using namespace std; int main(){     for(int i=202;i<2001;i++){         if(i%2==1 && i%3==0){             cout << i << endl;         }     } } ________________________________________ Soal No 2 #include <iostream> using namespace std; void cetakDiskon(double harga, int jumlah); int main(){     string barang;     cout << "Masukan nama brang: ";     cin >> barang;     double harga;     cout << "Masukan harga barang:";     cin >> harga;     int jumlah;     cout << "Masukan jumlah barang yang dibeli:";     cin >> jumlah;     cout << endl;     cout << "Barang: " << barang << endl;     cetakDiskon(harga, jumlah); } void cetakDiskon(double harga, int jumlah){     double hargaTotal = harga * jumlah;     double diskonTotal = (harga * jumlah * 5)/100;     cout << "Harga satuan: " << harga << endl;     cou

Jawaban Struktur Data

Soal No 1  /**  * by Nama Anda  * NIM Anda */ #include<iostream> using namespace std; void pemnjumlahanSubset(int arr[],int l,int r, int sum){     if(l>r){         cout<<sum<<" ";         return;     }     pemnjumlahanSubset(arr,l+1,r,sum+arr[l]);     pemnjumlahanSubset(arr,l+1,r,sum);         } int main(){     int n;     cin>>n;     int arr[n];     for( int i =0 ;i<n;i++){         cin>>arr[i];     }     pemnjumlahanSubset(arr,0,n-1,0);     return 0; } ________________________________________________________ Soal No 2 /**  * by Nama Anda  * NIM Anda */ #include<iostream> using namespace std; int mundur(int a){     // a >= 0     cout<<a<<endl;     if(a>0)         mundur(a-1);     else          return 0;      } int main(){     int x;     cin>>x;     mundur(x); } ________________________________________________________ Soal No 3 #include <iostream> using namespace std; void swap(int *x,int *y){ int temp =