TUGAS KHUSUS STIKI MALANG
17.20 |
Diposting oleh
Unknown |
Edit Entri
Pekan Ilmiah Mahasiswa & Stiki Student Competition
Pekan Ilmiah Mahasiswa
merupakan ajang kompetisi yang diselenggarakan oleh STIKI Malang untuk diikuti
oleh internal mahasiswa STIKI sebagai sarana untuk mempromosikan kegiatan
ilmiah terutama kompetisi ilmiah agar mahasiswa STIKI lebih familiar dengan
model kegiatan kompetisi yang ada, baik yang dilaksanakan oleh internal STIKI
maupun instansi non-STIKI.
Sedangkan SSC merupakan ajang kompetisi yang
diperuntukkan bagi siswa SMA/SMK se-Malang Raya sebagai sarana untuk
mengenalkan kampus STIKI kepada siswa SMA/SMK. Pada kegiatan PIM ke-V dan SSC
tahun ini diangkat tema yaitu ”Technology
enriches your creativity”, diharapkan mahasiswa STIKI dan siswa SMA
se-Malang Raya tidak hanya dapat berfikir atau berencana saja. Akan tetapi
mampu untuk mrealisasikan ide – ide atau gagasan – gagasan positif yang telah
dihasilkan sehingga ide/gagasan tersebut tidak hanya menjadi sebuah angan –
angan, melainkan ide/gagasan tersebut dapat terealisasi dan bermanfaat bagi
semua pihak.
Kegiatan kompetisi Pekan
Ilmiah Mahasiswa dan SSC STIKI ini diselenggarakan dengan tujuan untuk:
1. Meningkatkan minat mahasiswa dalam
mengikuti kegiatan ilmiah.
2. Mengembangkan kreatifitas mahasiswa baik
di bidang IT maupun non-IT dan di bidang ilmiah dan non-ilmiah.
3.
Sebagai sarana untuk membangun academic environment yang lebih baik lagi.
4. Meningkatkan kualitas dan kuantitas dari
karya ilmiah mahasiswa.
5. Menjadi sarana untuk mempersiapkan
mahasiswa agar dapat bersaing dalam mengikuti ajang kompetisi ilmiah di tingkat
yang lebih tinggi.
6. Mengenalkan Kampus STIKI kepada siswa SMA
dan SMK di Malang Raya agar mereka tertarik untuk melanjutkan pendidikannya di
STIKI Malang.
Game SOS
16.33 |
Diposting oleh
Unknown |
Edit Entri
Dalam postingan saya kali ini, saya akan memberikan source code tentang permainan yang umum dan sederhana yang biasa di temukan di kehidupan sehari-hari, yaitu game SOS/XOX atau sejenisnya, langsung saja berikut saya cantumkan source codenya yg menggunakan program java netbeans...
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package sos;
import java.util.Scanner;
/**
*
* @author Chiput_Konan
*/
public class Sos {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String ar[] = {"-","-","-","-","-","-","-","-","-"};
int player1 = 0;
int player2 = 0;
int index = 0;
for(int l = 0; l<3; l++)
{
for(int j = 0; j<3; j++)
{
System.out.print(ar[j]);
}
System.out.print("\n");
}
for(int j = 0;j < 9;j++)
{
//Input position and letter
System.out.println("Enter the position number: ");
index = input.nextInt();
input.nextLine();
System.out.println("Enter (S or O): ");
ar[index - 1] = input.nextLine();
//Output for the game
for(int l = 0; l<9; l++)
{
System.out.print(ar[l]);
if(l == 2)
{
System.out.println();
}
else if(l == 5)
{
System.out.println();
}
else if(l == 8)
{
System.out.println();
}
}
//condition
if((ar[0]+ar[1]+ar[2]).equals("SOS"))
{
if(j%2 == 0)
{
player1++;
System.out.println("Player 1: "+player1+" Player 2: "+player2);
}
else if( j % 2 != 0)
{
player2++;
System.out.println("Player 1: "+player1+" Player 2: "+player2);
}
}
else if((ar[3]+ar[4]+ar[5]).equals("SOS"))
{
if(j%2 == 0)
{
player1++;
System.out.println("Player 1: "+player1+" Player 2: "+player2);
}
else if( j % 2 != 0)
{
player2++;
System.out.println("Player 1: "+player1+" Player 2: "+player2);
}
}
else
{
System.out.println("Player 1: "+player1+" Player 2: "+player2);
}
//end of condition
}
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package sos;
import java.util.Scanner;
/**
*
* @author Chiput_Konan
*/
public class Sos {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String ar[] = {"-","-","-","-","-","-","-","-","-"};
int player1 = 0;
int player2 = 0;
int index = 0;
for(int l = 0; l<3; l++)
{
for(int j = 0; j<3; j++)
{
System.out.print(ar[j]);
}
System.out.print("\n");
}
for(int j = 0;j < 9;j++)
{
//Input position and letter
System.out.println("Enter the position number: ");
index = input.nextInt();
input.nextLine();
System.out.println("Enter (S or O): ");
ar[index - 1] = input.nextLine();
//Output for the game
for(int l = 0; l<9; l++)
{
System.out.print(ar[l]);
if(l == 2)
{
System.out.println();
}
else if(l == 5)
{
System.out.println();
}
else if(l == 8)
{
System.out.println();
}
}
//condition
if((ar[0]+ar[1]+ar[2]).equals("SOS"))
{
if(j%2 == 0)
{
player1++;
System.out.println("Player 1: "+player1+" Player 2: "+player2);
}
else if( j % 2 != 0)
{
player2++;
System.out.println("Player 1: "+player1+" Player 2: "+player2);
}
}
else if((ar[3]+ar[4]+ar[5]).equals("SOS"))
{
if(j%2 == 0)
{
player1++;
System.out.println("Player 1: "+player1+" Player 2: "+player2);
}
else if( j % 2 != 0)
{
player2++;
System.out.println("Player 1: "+player1+" Player 2: "+player2);
}
}
else
{
System.out.println("Player 1: "+player1+" Player 2: "+player2);
}
//end of condition
}
}
}
Binary Tree Search
15.22 |
Diposting oleh
Unknown |
Edit Entri
Metode Binary Search merupakan metode yang membandingkan batas
atas dan batas bawah dalam suatu kumpulan array, sampai di temukannya
angka yang di tuju. berikut saya cantumkan source codenya dan flowchartnya :
import java.util.Scanner; class BinarySearch { public static void main(String args[]) { int c, first, last, middle, n, search, array[]; Scanner in = new Scanner(System.in); System.out.println("Enter number of elements"); n = in.nextInt(); array = new int[n]; System.out.println("Enter " + n + " integers"); for (c = 0; c < n; c++) array[c] = in.nextInt(); System.out.println("Enter value to find"); search = in.nextInt(); first = 0; last = n - 1; middle = (first + last)/2; while( first <= last ) { if ( array[middle] < search ) first = middle + 1; else if ( array[middle] == search ) { System.out.println(search + " found at location " + (middle + 1) + "."); break; } else last = middle - 1; middle = (first + last)/2; } if ( first > last ) System.out.println(search + " is not present in the list.\n"); } }
Order LinkedList
16.40 |
Diposting oleh
Unknown |
Edit Entri
Linked list tidak lain adalah suatu struktur data yg merupakan suatu
rangkaian atau daftar record berjenis sama. Kemudian dihubungkan melalui
bantuan pointer. Pengalokasian daftar dapat dilakukan secara dinamis
sehingga isi dari daftar dapat dimanipulasi. Untuk memahami
Berikut saya cantumkan sourcecode dari Order LinkedList
package ordered.linkedlist;
class Node {
int data;
Node prev;
Node next;
}
public class OrderedLinkedList {
static Node head, tail;
static void insert(int new_data) {
Node new_node = new Node();
new_node.data = new_data;
if (head == null && tail == null) { // Jika LinkList Kosong
head = new_node;
tail = new_node;
} else if (new_node.data <= head.data) { //new_data < head
head.prev = new_node;
new_node.next = head;
head = new_node;
} else if (new_node.data >= tail.data) { //new_data > tail
new_node.prev = tail;
tail.next = new_node;
tail = new_node;
} else { //data di antara link list
Node position = head;
while (position.data < new_node.data) {
position = position.next;
}
position.prev.next = new_node;
new_node.prev = position.prev;
position.prev = new_node; //data sebelum position berganti jadi new_node
new_node.next = position;
}
}
static void delete(int data) {
if (head == null && tail == null) {
// ridak bisa dihapus, karena tidak ada data
} else if (head == tail && head.data == data) { //satu data saja
head = null;
tail = null;
} else if (head.data == data) { //data yg dihapus ==head
head.next.prev = null;
head = head.next;
} else if (tail.data == data) { //data yg dihapus == tail
tail.prev.next = null;
tail = tail.prev;
} else {
Node position = head;
while (position!= null && position.data != data) {
position = position.next;
}
if (position == null) {
System.out.println("Data Tidak Ada");
} else if (position != null) {
Node previous = position.prev;
Node next = position.next;
previous.next = next;
next.prev = previous;
}
}
}
static void traverse() { //sama dengan view() pada double_linklist
Node x = head;
while (x != null) {
System.out.print(x.data + " - ");
x = x.next;
}
System.out.println();
}
public static void main(String[] args) {
insert(7);
insert(16);
insert(4);
insert(6);
insert(8);
insert(15);
insert(13);
traverse(10);
}
}
Berikut saya cantumkan sourcecode dari Order LinkedList
package ordered.linkedlist;
class Node {
int data;
Node prev;
Node next;
}
public class OrderedLinkedList {
static Node head, tail;
static void insert(int new_data) {
Node new_node = new Node();
new_node.data = new_data;
if (head == null && tail == null) { // Jika LinkList Kosong
head = new_node;
tail = new_node;
} else if (new_node.data <= head.data) { //new_data < head
head.prev = new_node;
new_node.next = head;
head = new_node;
} else if (new_node.data >= tail.data) { //new_data > tail
new_node.prev = tail;
tail.next = new_node;
tail = new_node;
} else { //data di antara link list
Node position = head;
while (position.data < new_node.data) {
position = position.next;
}
position.prev.next = new_node;
new_node.prev = position.prev;
position.prev = new_node; //data sebelum position berganti jadi new_node
new_node.next = position;
}
}
static void delete(int data) {
if (head == null && tail == null) {
// ridak bisa dihapus, karena tidak ada data
} else if (head == tail && head.data == data) { //satu data saja
head = null;
tail = null;
} else if (head.data == data) { //data yg dihapus ==head
head.next.prev = null;
head = head.next;
} else if (tail.data == data) { //data yg dihapus == tail
tail.prev.next = null;
tail = tail.prev;
} else {
Node position = head;
while (position!= null && position.data != data) {
position = position.next;
}
if (position == null) {
System.out.println("Data Tidak Ada");
} else if (position != null) {
Node previous = position.prev;
Node next = position.next;
previous.next = next;
next.prev = previous;
}
}
}
static void traverse() { //sama dengan view() pada double_linklist
Node x = head;
while (x != null) {
System.out.print(x.data + " - ");
x = x.next;
}
System.out.println();
}
public static void main(String[] args) {
insert(7);
insert(16);
insert(4);
insert(6);
insert(8);
insert(15);
insert(13);
traverse(10);
}
}
08.10 |
Diposting oleh
Unknown |
Edit Entri
Assalamu Alaikum Warahmatullahi wabarakatu, sebelumnya saya selalu membahas tentang C++, nah kali ini tetap saya masih membahas tentang C++ tapi pertemuan kali ini saya ingin sharing hasil laporan matakuliah Algoritma saya, yaitu pembuatan aplikasi pembelian ticket bioskop, nahh langsung saja lihat dibawa ini Source Code saya menggunakan bahasa program C++
PROGRAM BIOSKOP
#include <iostream.h>
#include <conio.h>
void main()
{
int pil,a;
do
{
clrscr();
cout<<"::::::::::: SELAMAT DATANG DI SISTEM TERPADU WISATA CINEMA :::::::::::\n\n";
cout<<"<-------------------------------------------->\n";
cout<<" | oleh : Muh.Adhar (141111020) |\n";
cout<<"<-------------------------------------------->\n\n";
cout<<" -----------MENU-------------\n";
cout<<"| 1. PEMBELIAN TIKET |\n";
cout<<"| 2. CEK SISA KURSI |\n";
cout<<"| 3. LAPORAN PENJUALAN TIKET |\n";
cout<<"| 4. KELUAR |\n\n";
cout<<"Masukkan pilihan anda : ";
cin>>pil;
switch (pil)
{
case 1:
mulai:
clrscr();
int jenis,jumlah,total_tiket;
char* jenis_txt;
char ulang;
cout<<":::::::> SELAMAT DATANG DI WISATA CINEMA <:::::::\n\n";
cout<<"Harga tiket :\nDewasa\t: Rp. 20.000,-\nAnak\t: Rp. 15.000,-\n\n";
cout<<"Silahkan input jenis tiket\n";
cout<<"1 : Dewasa\n2 : Anak-anak\n\n";
cout<<"Jenis : "; cin>>jenis;
cout<<"\n\nSilahkan input jumlah tiket\n";
cout<<"Jumlah : "; cin>>jumlah;
if (jenis==1)
{
total_tiket=jumlah*20000;
jenis_txt="Dewasa";
}
else if (jenis==2)
{
total_tiket=jumlah*15000;
jenis_txt="Anak-anak";
}
else
{
cout<<"\n\nInput Jenis Salah, Mohon ulangi lagi";
getch();
goto mulai;
}
clrscr();
cout<<":::::::> SELAMAT DATANG DI WISATA CINEMA <:::::::\n\n";
cout<<"Jenis tiket : "<<jenis_txt<<endl;
cout<<"Jumlah pembelian : "<<jumlah<<"\n";
cout<<"---------------------------------- \n";
cout<<"TOTAL : Rp. "<<total_tiket<<",-";
getch();
break;
case 2:
clrscr();
int kursi_isi[4],kursi_kosong[4];
cout<<":::::::::::::::::: CEK SISA KURSI ::::::::::::::::::\n\n";
cout<<"PETUNJUK :\n-> Jumlah kursi di tiap Wisata adalah 50 kursi\n";
cout<<"-> Silahkan masukkan jumlah kursi yang telah ditempati\n\n";
a=0;
do
{
cout<<"Wisata "<<a+1<<" : ";
cin>>kursi_isi[a];
a++;
}
while (a<4);
for (a=0;a<4;a++)
kursi_kosong[a]=50-kursi_isi[a];
clrscr();
cout<<":::::::::::::::::: CEK SISA KURSI ::::::::::::::::::\n\n";
cout<<":\tSISA KURSI\t:\n";
cout<<"-------------------------\n";
for (a=0;a<4;a++)
{
cout<<" Wisata "<<a+1<<" : "<<kursi_kosong[a];
cout<<"\n-------------------------\n";
}
getch();
break;
case 3:
clrscr();
int wisata_anak[4],wisata_dewasa[4],total[4];
cout<<"::::::::::: LAPORAN PENJUALAN TIKET :::::::::::\n\n";
for (a=0;a<4;a++)
{
cout<<"Silahkan masukkan data penjualan tiket Wisata "<<a+1<<" : ";
cout<<"\nAnak-anak : "; cin>>wisata_anak[a];
cout<<"Dewasa : "; cin>>wisata_dewasa[a];
cout<<endl;
}
for (a=0;a<4;a++)
total[a]=wisata_anak[a]+wisata_dewasa[a];
clrscr();
cout<<"::::::::::: LAPORAN PENJUALAN TIKET :::::::::::\n\n";
cout<<"----------------- PENJUALAN ------------------\n";
cout<<"\nWisata / Anak-anak / Dewasa / Total Penjualan\n";
for (a=0;a<4;a++)
{
cout<<a+1<<" "<<wisata_anak[a]<<" "<<wisata_dewasa[a];
cout<<" "<<total[a]<<endl;
}
getch();
break;
}
}
while (pil!=4);
}
07.35 |
Diposting oleh
Unknown |
Edit Entri
Hayy apa kabar, kembali lagi dengan saya konan kato ingin berbagi di blok saya tentang Linked Lists di bahasa programan C++, langsung saja lihat Source code C++ di bawah ini
Singly Linked Lists
/* definition of the list node class */
class Node
{
friend class LinkedList;
private:
int _value; /* data, can be any data type, but use integer for easiness */
Node *_pNext; /* pointer to the next node */
public:
/* Constructors with No Arguments */
Node(void)
: _pNext(NULL)
{ }
/* Constructors with a given value */
Node(int val)
: _value(val), _pNext(NULL)
{ }
/* Constructors with a given value and a link of the next node */
Node(int val, Node* next)
: _value(val), _pNext(next)
{}
/* Getters */
int getValue(void)
{ return _value; }
Node* getNext(void)
{ return _pNext; }
};
/* definition of the linked list class */
class LinkedList
{
private:
/* pointer of head node */
Node *_pHead;
/* pointer of tail node */
Node *_pTail;
public:
/* Constructors with No Arguments */
LinkedList(void);
/* Constructors with a given value of a list node */
LinkedList(int val);
/* Destructor */
~LinkedList(void);
/* Traversing the list and printing the value of each node */
void traverse_and_print();
};
LinkedList::LinkedList()
{
/* Initialize the head and tail node */
_pHead = _pTail = NULL;
}
LinkedList::LinkedList(int val)
{
/* Create a new node, acting as both the head and tail node */
_pHead = new Node(val);
_pTail = _pHead;
}
LinkedList::~LinkedList()
{
/*
* Leave it empty temporarily.
* It will be described in detail in the example "How to delete a linkedlist".
*/
}
void LinkedList::traverse_and_print()
{
Node *p = _pHead;
/* The list is empty? */
if (_pHead == NULL) {
cout << "The list is empty" << endl;
return;
}
cout << "LinkedList: ";
/* A basic way of traversing a linked list */
while (p != NULL) { /* while there are some more nodes left */
/* output the value */
cout << p->_value;
/* The pointer moves along to the next one */
p = p->_pNext;
}
cout << endl;
}
int main(int argc, const char * argv[])
{
/* Create an empty list */
LinkedList list1;
cout << "Created an empty list named list1." << endl;
/* output the result */
cout << "list1:" << endl;
list1.traverse_and_print();
/* Create a list with only one node */
LinkedList list2(10);
cout << "Created a list named list2 with only one node." << endl;
/* output the result */
cout << "list2:" << endl;
list2.traverse_and_print();
return 0;
}
class Node
{
friend class LinkedList;
private:
int _value; /* data, can be any data type, but use integer for easiness */
Node *_pNext; /* pointer to the next node */
public:
/* Constructors with No Arguments */
Node(void)
: _pNext(NULL)
{ }
/* Constructors with a given value */
Node(int val)
: _value(val), _pNext(NULL)
{ }
/* Constructors with a given value and a link of the next node */
Node(int val, Node* next)
: _value(val), _pNext(next)
{}
/* Getters */
int getValue(void)
{ return _value; }
Node* getNext(void)
{ return _pNext; }
};
/* definition of the linked list class */
class LinkedList
{
private:
/* pointer of head node */
Node *_pHead;
/* pointer of tail node */
Node *_pTail;
public:
/* Constructors with No Arguments */
LinkedList(void);
/* Constructors with a given value of a list node */
LinkedList(int val);
/* Destructor */
~LinkedList(void);
/* Traversing the list and printing the value of each node */
void traverse_and_print();
};
LinkedList::LinkedList()
{
/* Initialize the head and tail node */
_pHead = _pTail = NULL;
}
LinkedList::LinkedList(int val)
{
/* Create a new node, acting as both the head and tail node */
_pHead = new Node(val);
_pTail = _pHead;
}
LinkedList::~LinkedList()
{
/*
* Leave it empty temporarily.
* It will be described in detail in the example "How to delete a linkedlist".
*/
}
void LinkedList::traverse_and_print()
{
Node *p = _pHead;
/* The list is empty? */
if (_pHead == NULL) {
cout << "The list is empty" << endl;
return;
}
cout << "LinkedList: ";
/* A basic way of traversing a linked list */
while (p != NULL) { /* while there are some more nodes left */
/* output the value */
cout << p->_value;
/* The pointer moves along to the next one */
p = p->_pNext;
}
cout << endl;
}
int main(int argc, const char * argv[])
{
/* Create an empty list */
LinkedList list1;
cout << "Created an empty list named list1." << endl;
/* output the result */
cout << "list1:" << endl;
list1.traverse_and_print();
/* Create a list with only one node */
LinkedList list2(10);
cout << "Created a list named list2 with only one node." << endl;
/* output the result */
cout << "list2:" << endl;
list2.traverse_and_print();
return 0;
}
Circularly Linked Lists
#include <iostream>
using namespace std;
template <class T>
struct Node
{
T data;
Node * next;
Node(T data) : data(data), next(NULL) {}
};
template <class T>
class CircularLinkedList
{
public:
CircularLinkedList() : head(NULL) {}
~CircularLinkedList();
void addNode(T data);
void deleteNode(T data);
template <class U>
friend std::ostream & operator<<(std::ostream & os, const CircularLinkedList<U> & cll);
private:
Node<T> * head;
};
template <class T>
CircularLinkedList<T>::~CircularLinkedList()
{
if (head)
{
Node<T> * tmp = head;
while (tmp->next != head)
{
Node<T> * t = tmp;
tmp = tmp->next;
delete(t);
}
delete tmp;
head = NULL;
}
}
template <class T>
void CircularLinkedList<T>::addNode(T data)
{
Node<T> * t = new Node<T>(data);
if (head == NULL)
{
t->next = t;
head = t;
return;
}
Node<T> * tmp = head;
while (tmp->next != head)
{
tmp = tmp->next;
}
tmp->next = t;
t->next = head;
}
template <class T>
void CircularLinkedList<T>::deleteNode(T data)
{
Node<T> * tmp = head;
Node<T> * prev = NULL;
while (tmp->next != head)
{
if (tmp->data == data) break;
prev = tmp;
tmp = tmp->next;
}
if (tmp == head)
{
while (tmp->next != head)
{
tmp = tmp->next;
}
tmp->next = head->next;
delete head;
head = tmp->next;
}
else
{
prev->next = tmp->next;
delete tmp;
}
}
template <class U>
std::ostream & operator<<(std::ostream & os, const CircularLinkedList<U> & cll)
{
Node<U> * head = cll.head;
if (head)
{
Node<U> * tmp = head;
while (tmp->next != head)
{
os << tmp->data << " ";
tmp = tmp->next;
}
os << tmp->data;
}
return os;
}
int main()
{
CircularLinkedList<int> cll;
cll.addNode(1);
cll.addNode(2);
cll.addNode(3);
cll.addNode(4);
cll.addNode(5);
cout << cll << endl;
cll.deleteNode(3);
cll.deleteNode(1);
cll.deleteNode(5);
cout << cll << endl;
return 0;
}
Doubly Linked Lists
#include<iostream>
using namespace std;
/* Linked list structure */
struct list {
struct list *prev;
int data;
struct list *next;
} *node = NULL, *first = NULL, *last = NULL, *node1 = NULL, *node2 = NULL;
class linkedlist {
public:
/* Function for create/insert node at the beginning of Linked list */
void insert_beginning() {
list *addBeg = new list;
cout << "Enter value for the node:" << endl;
cin >> addBeg->data;
if(first == NULL) {
addBeg->prev = NULL;
addBeg->next = NULL;
first = addBeg;
last = addBeg;
cout << "Linked list Created!" << endl;
}
else {
addBeg->prev = NULL;
first->prev = addBeg;
addBeg->next = first;
first = addBeg;
cout << "Data Inserted at the beginning of the Linked list!" << endl;
}
}
/* Function for create/insert node at the end of Linked list */
void insert_end() {
list *addEnd = new list;
cout << "Enter value for the node:" << endl;
cin >> addEnd->data;
if(first == NULL) {
addEnd->prev = NULL;
addEnd->next = NULL;
first = addEnd;
last = addEnd;
cout << "Linked list Created!" << endl;
}
else {
addEnd->next = NULL;
last->next = addEnd;
addEnd->prev = last;
last = addEnd;
cout << "Data Inserted at the end of the Linked list!" << endl;
}
}
/* Function for Display Linked list */
void display() {
node = first;
cout << "List of data in Linked list in Ascending order!" << endl;
while(node != NULL) {
cout << node->data << endl;
node = node->next;
}
node = last;
cout << "List of data in Linked list in Descending order!" << endl;
while(node != NULL) {
cout << node->data << endl;
node = node->prev;
}
}
/* Function for delete node from Linked list */
void del() {
int count = 0, number, i;
node = node1 = node2 = first;
for(node = first; node != NULL; node = node->next)
cout << "Enter value for the node:" << endl;
count++;
display();
cout << count << " nodes available here!" << endl;
cout << "Enter the node number which you want to delete:" << endl;
cin >> number;
if(number != 1) {
if(number < count && number > 0) {
for(i = 2; i <= number; i++)
node = node->next;
for(i = 2; i <= number-1; i++)
node1 = node1->next;
for(i = 2; i <= number+1; i++)
node2 = node2->next;
node2->prev = node1;
node1->next = node2;
node->prev = NULL;
node->next = NULL;
node = NULL;
}
else if(number == count) {
node = last;
last = node->prev;
last->next = NULL;
node = NULL;
}
else
cout << "Invalid node number!" << endl;
}
else {
node = first;
first = node->next;
first->prev = NULL;
node = NULL;
}
cout << "Node has been deleted successfully!" << endl;
}
};
int main() {
int op = 0;
linkedlist llist = linkedlist();
while(op != 4) {
cout << "1. Insert at the beginning\n2. Insert at the end\n3. Delete\n4. Display\n5. Exit" << endl;
cout << "Enter your choice:" << endl;
cin >> op;
switch(op) {
case 1:
llist.insert_beginning();
break;
case 2:
llist.insert_end();
break;
case 3:
llist.del();
break;
case 4:
llist.display();
break;
case 5:
cout << "Bye Bye!" << endl;
return 0;
break;
default:
cout << "Invalid choice!" << endl;
}
}
return 0;
}
06.20 |
Diposting oleh
Unknown |
Edit Entri
assalamu alaikum,,, kembali lagi dengan saya konan kato, kesempatan kali ini saya akan membagikan post terbaru saya yaitu program pecahan menggunakan bahasa pemrograman C++, langsung saja berikut ini source code C++
#include
using namespace std;
void menu();
void samakan(int& a, int& b, int& c, int& d)
{
int x, y;
for (int i=1;i<=(b * d);i++)
{
if ((i % b == 0)&&(i % d == 0))
{
x = i/b;
y = i/d;
break;
}
}
a = a * x; b = b * x; c = c * y; d = d * y;
}
void jumlah()
{
int a, b, c, d, e, f;
cout<<" Pecahan A = ";cin>>a;
cout<<" --\n";
cout<<" ";cin>>b;
cout<
cout<<" Pecahan B = ";cin>>c;
cout<<" --\n";
cout<<" ";cin>>d;
cout<
if (b != d)
samakan(a,b,c,d);
e=a+c;
f=b;
cout<<" A + B = "<<
cout<<" --\n";
cout<<" "<<
cout<
for (int s=0;s<1000000000;s++);
menu();
}
void kurang()
{
int a, b, c, d, e, f;
cout<<" Pecahan A = ";cin>>a;
cout<<" --\n";
cout<<" ";cin>>b;
cout<
cout<<" Pecahan B = ";cin>>c;
cout<<" --\n";
cout<<" ";cin>>d;
cout<
if (b != d)
samakan(a,b,c,d);
e=a-c;
f=b;
cout<<" A - B = "<<
cout<<" --\n";
cout<<" "<<
cout<
for (int s=0;s<1000000000;s++);
menu();
}
void kali()
{
int a, b, c, d, e, f;
cout<<" Pecahan A = ";cin>>a;
cout<<" --\n";
cout<<" ";cin>>b;
cout<
cout<<" Pecahan B = ";cin>>c;
cout<<" --\n";
cout<<" ";cin>>d;
cout<
e=a*c;
f=b*d;
cout<<" A x B = "<<
cout<<" --\n";
cout<<" "<<
cout<
for (int s=0;s<1000000000;s++);
menu();
}
void bagi()
{
int a, b, c, d, e, f;
cout<<" Pecahan A = ";cin>>a;
cout<<" --\n";
cout<<" ";cin>>b;
cout<
cout<<" Pecahan B = ";cin>>c;
cout<<" --\n";
cout<<" ";cin>>d;
cout<
e=a*d;
f=b*c;
cout<<" A : B = "<<
cout<<" --\n";
cout<<" "<<
cout<
for (int s=0;s<1000000000;s++);
menu();
}
void menu()
{
system("cls");
char pil;
cout<<" OPERASI PECAHAN\n";
cout<<"=======================================================\n";
cout<<" a. Operasi Penjumlahan\n";
cout<<" b. Operasi Pengurangan\n";
cout<<" c. Operasi Perkalian\n";
cout<<" d. Operasi Pembagian\n";
cout<<" e. Keluar\n";
cout<<"=======================================================\n";
cout<<" Pilihan Operasi [a..d] = ";cin>>pil;
cout<
switch (pil)
{
case 'a' : jumlah();
break;
case 'b' : kurang();
break;
case 'c' : kali();
break;
case 'd' : bagi();
break;
}
}
void main()
{
menu();
cout<<"=======================================================\n";
cout<<" copyleft(c)BananaSoft2009\n";
cout<<
}
#include
using namespace std;
void menu();
void samakan(int& a, int& b, int& c, int& d)
{
int x, y;
for (int i=1;i<=(b * d);i++)
{
if ((i % b == 0)&&(i % d == 0))
{
x = i/b;
y = i/d;
break;
}
}
a = a * x; b = b * x; c = c * y; d = d * y;
}
void jumlah()
{
int a, b, c, d, e, f;
cout<<" Pecahan A = ";cin>>a;
cout<<" --\n";
cout<<" ";cin>>b;
cout<
cout<<" Pecahan B = ";cin>>c;
cout<<" --\n";
cout<<" ";cin>>d;
cout<
if (b != d)
samakan(a,b,c,d);
e=a+c;
f=b;
cout<<" A + B = "<<
cout<<" --\n";
cout<<" "<<
cout<
for (int s=0;s<1000000000;s++);
menu();
}
void kurang()
{
int a, b, c, d, e, f;
cout<<" Pecahan A = ";cin>>a;
cout<<" --\n";
cout<<" ";cin>>b;
cout<
cout<<" Pecahan B = ";cin>>c;
cout<<" --\n";
cout<<" ";cin>>d;
cout<
if (b != d)
samakan(a,b,c,d);
e=a-c;
f=b;
cout<<" A - B = "<<
cout<<" --\n";
cout<<" "<<
cout<
for (int s=0;s<1000000000;s++);
menu();
}
void kali()
{
int a, b, c, d, e, f;
cout<<" Pecahan A = ";cin>>a;
cout<<" --\n";
cout<<" ";cin>>b;
cout<
cout<<" Pecahan B = ";cin>>c;
cout<<" --\n";
cout<<" ";cin>>d;
cout<
e=a*c;
f=b*d;
cout<<" A x B = "<<
cout<<" --\n";
cout<<" "<<
cout<
for (int s=0;s<1000000000;s++);
menu();
}
void bagi()
{
int a, b, c, d, e, f;
cout<<" Pecahan A = ";cin>>a;
cout<<" --\n";
cout<<" ";cin>>b;
cout<
cout<<" Pecahan B = ";cin>>c;
cout<<" --\n";
cout<<" ";cin>>d;
cout<
e=a*d;
f=b*c;
cout<<" A : B = "<<
cout<<" --\n";
cout<<" "<<
cout<
for (int s=0;s<1000000000;s++);
menu();
}
void menu()
{
system("cls");
char pil;
cout<<" OPERASI PECAHAN\n";
cout<<"=======================================================\n";
cout<<" a. Operasi Penjumlahan\n";
cout<<" b. Operasi Pengurangan\n";
cout<<" c. Operasi Perkalian\n";
cout<<" d. Operasi Pembagian\n";
cout<<" e. Keluar\n";
cout<<"=======================================================\n";
cout<<" Pilihan Operasi [a..d] = ";cin>>pil;
cout<
switch (pil)
{
case 'a' : jumlah();
break;
case 'b' : kurang();
break;
case 'c' : kali();
break;
case 'd' : bagi();
break;
}
}
void main()
{
menu();
cout<<"=======================================================\n";
cout<<" copyleft(c)BananaSoft2009\n";
cout<<
}
Langganan:
Postingan (Atom)