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;

}

Monday, 1 April 2024

Program C++ Bentuk Love

#include <iostream>

#include <conio.h>

using namespace std;

int main(){

int i,j;

for(i=1;i<=22;i++)

{

         for(j=1;j<=60;j++){

Program Menu Pilihan

#include <iostream>

#include <conio.h>

#include <stdlib.h>

using namespace std;

/**-------------------------

 Algoritma dan Pemrograman

 ---------------------------**/

int main() {

    unsigned int pilihan;

    cout << "MENU PILIHAN" << endl;

    cout << "------------" << endl;

    cout << "1. hitung luas lingkaran" << endl;

    cout << "2. hitung luas persegi" << endl;

    cout << "3. hitung luas segitiga" << endl;

    cout << "4. exit" << endl;

    cout << "------------" << endl;

   while (pilihan>=0){

    cout << "pilihan anda (1/2/3/4)         : "; cin >> pilihan;

     if (pilihan== 1) 

{