Thursday, 11 July 2024

Program Perbaikan UAS 2

 #include <iostream>

#include <string>

#include <iomanip>

#include <cmath>

using namespace std;


bool cekPrima(int num) {

    if (num <= 1) return false;

    for (int i = 2; i <= sqrt(num); i++) {

        if (num % i == 0) return false;

    }

    return true;

}

Program Perbaikan UAS 1

 #include <iostream>

#include <iomanip>

#include <string>

using namespace std;


struct Barang {

    string nama;

    double harga;

    int jumlah;

};


struct Pelanggan {

    string NIK;

    string nama;

    string alamat;

    int umur;

    long pembelian;

};


int main() {

    string password = "password";


    string inputPassword;


    bool passwordBenar = false;

Thursday, 20 June 2024

Program karyawan

 struct karyawan {

    string nama;

    char golongan;

    int jumlah_anak;

    int gapok;

    int JA;

    int Ttl_Gaji;

    int Ttl_jmlank;

};


int main() {

    int n;

    cout << "Masukan Jumlah Karyawan : ";

    cin >> n;

Program Belanja

 #include <conio.h>

#include <stdio.h>

#include <iostream>

#include <iomanip>

#include <fstream>

#include <cmath>

using namespace std;


int main( )

{

   struct program{

    int hb;

Program Mahasiswa

 #include <conio.h>

#include <stdio.h>

#include <iostream>

#include <iomanip>

#include <fstream>

#include <cmath>

#include <string>

#include<windows.h>

using namespace std;


int main()

{

Sunday, 21 April 2024

Buble Sort

 #include<iostream>

using namespace std;

int main()

{

int temp;

//int x[]={10,5,2,7,8,3};

int x[]={17,23,12,00,49};

int j = sizeof(x)/sizeof(*x);

cout<<" X : ";

for(int i=0; i<j; i++)

{

cout<<x[i]<<" ";

}

Selection Sort

 #include<iostream>

using namespace std;


int main()

{

int x[]={3,4,6,5,2};

int j = sizeof(x)/sizeof(*x);

int temp,pos,y;

cout<<" y : ";

for(int i=0; i<j;i++){

cout<<x[i]<<" ";

}

cout<<endl;

//pengurutan selection

for(int a=0; a<j;a++){

temp=x[a];

pos=a;

for(int b=a;b<j;b++){

if(x[b]<temp){

temp=x[b];

pos = b;

}