sebuah game untuk memenuhi tugas UAS algoritma menggunakan C++
#include <iostream>
#include <conio.h>
#include <windows.h>
#include <cstdlib>
using namespace std;
void gotoxy(int x, int y)
{
COORD coord;
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
}
main()
{
int i=1, skor=0;
char p, comp, comp2, x, lanjut;
for(int a = 20;a < 60;a++)
{
gotoxy(a,1);cout << "=";
gotoxy(a,3);cout <<"-";
gotoxy(a,5);cout << "=";
}
gotoxy(35,2);
cout << "Game Kuis C++";
gotoxy(31,4);
cout << "Ingin memulai [y/n] : "; cin >> p;
main :
while(p == 'y' || p == 'Y')
{
// clrscr();
system("cls");
for(int c = 20;c <= 60;c++)
{
gotoxy(c,1);cout << "=";
gotoxy(c,3);cout << "-";
gotoxy(c,9);cout << "=";
gotoxy(c,11);cout << "=";
}
gotoxy(20,12);cout << "Skor Sementara = " << skor;
gotoxy(36,2);cout << "Game C++";
gotoxy(20,4);cout << "Jawab Pertanyaan";
if (i==1)
{
gotoxy(23,5);cout << "sebutkan untuk judul cerita? ";
gotoxy(23,6);cout << "A. Plot";
gotoxy(23,7);cout << "B. Tema";
gotoxy(23,8);cout << "C. Alur";
comp='B';comp2='B';
}
else if(i==2)
{
gotoxy(23,5);cout << "majar berlebihan disebut juga sebagai?";
gotoxy(23,6);cout << "A. Majas Huper bola";
gotoxy(23,7);cout << "B. Majas personifikas ";
gotoxy(23,8);cout << "C. majas Alegori";
comp='A';comp2='a';
}
else if(i==3)
{
gotoxy(23,5);cout << "Sebutan Untuk Judul Cerita? ";
gotoxy(23,6);cout << "A. Plot";
gotoxy(23,7);cout << "B. Tema";
gotoxy(23,8);cout << "C. Alur";
comp='B';comp2='b';
}
else if(i==4)
{
gotoxy(23,5);cout << "Ibu Kota Indonesia Adalah ?";
gotoxy(23,6);cout << "A. Bandung";
gotoxy(23,7);cout << "B. Jakarta";
gotoxy(23,8);cout << "C. Makasar";
comp='B';comp2='b';
}
else if(i==5)
{
gotoxy(23,5);cout << "Pilih Kata Dibawah Ini yang Berarti Imbuhan ? ";
gotoxy(23,6);cout << "A. Menolak";
gotoxy(23,7);cout << "B. Tuntutan";
gotoxy(23,8);cout << "C. Prefiks";
comp='C';comp2='c';
}
else if(i==6)
{
gotoxy(23,5);cout << "Peran Baik Dalam Sebuah Cerita ? ";
gotoxy(23,6);cout << "A. Antagonis";
gotoxy(23,7);cout << "B. Protagonis";
gotoxy(23,8);cout << "C. Tritagonis";
comp='B';comp2='b';
}
else if(i==7)
{
gotoxy(23,5);cout << "Yang Termasuk Jenis Cerita Rakyat ? ";
gotoxy(23,6);cout << "A. Dongeng";
gotoxy(23,7);cout << "B. Drama";
gotoxy(23,8);cout << "C. Diskusi";
comp='A';comp2='a';
}
else if(i==8)
{
gotoxy(23,5);cout << "Mana Dibawah Ini Yang Termasuk Unsur 5W+1H ? ";
gotoxy(23,6);cout << "A. Whose";
gotoxy(23,7);cout << "B. Which";
gotoxy(23,8);cout << "C. When";
comp='C';comp2='c';
}
else if(i==9)
{
gotoxy(23,5);cout << "Gelar Yang Diberikan Bagi Seseorang Yang Ahli Dibidang Sastra ? ";
gotoxy(23,6);cout << "A. Sastrawan";
gotoxy(23,7);cout << "B. Komposer";
gotoxy(23,8);cout << "C. Musisi";
comp='A';comp2='a';
}
else if(i==10)
{
gotoxy(23,5);cout << "Raut Wajah Seseorang ? ";
gotoxy(23,6);cout << "A. Mimik";
gotoxy(23,7);cout << "B. Ekspresi";
gotoxy(23,8);cout << "C. Plot";
comp='B';comp2='b';
}
else if(i==11)
{
gotoxy(23,5);cout << "1Kilo meter berapa Centi meter ? ";
gotoxy(23,6);cout << "A. 1000cm";
gotoxy(23,7);cout << "B. 100cm";
gotoxy(23,8);cout << "C. 10cm";
comp='A';comp2='a';
}
else if(i==12)
{
gotoxy(23,5);cout << "800 centimeter berapa meter ? ";
gotoxy(23,6);cout << "A. 23 meter";
gotoxy(23,7);cout << "B. 48 meter";
gotoxy(23,8);cout << "C. 8 meter";
comp='C';comp2='c';
}
else if(i==13)
{
gotoxy(23,5);cout << "A*T*1/2 rumus untuk apa ? ";
gotoxy(23,6);cout << "A. Jajargenjang";
gotoxy(23,7);cout << "B. Persegi";
gotoxy(23,8);cout << "C. Lingkarang";
comp='B';comp2='b';
}
else if(i==14)
{
gotoxy(23,5);cout << "10*2:5= ? ";
gotoxy(23,6);cout << "A. 8";
gotoxy(23,7);cout << "B. 4";
gotoxy(23,8);cout << "C. 14";
comp='B';comp2='b';
}
else if(i==15)
{
gotoxy(23,5);cout << "Rumus Lingkaran? ";
gotoxy(23,6);cout << "A. A*T*3.14";
gotoxy(23,7);cout << "B. A*S*S*S*S";
gotoxy(23,8);cout << "C. A*L*T";
comp='A';comp2='a';
}
else if(i==16)
{
gotoxy(23,5);cout << "KPK Dari 2 dan 3? ";
gotoxy(23,6);cout << "A. 9";
gotoxy(23,7);cout << "B. 7";
gotoxy(23,8);cout << "C. 6";
comp='C';comp2='c';
}
else if(i==17)
{
gotoxy(23,5);cout << "Apa itu Relasi ? ";
gotoxy(23,6);cout << "A. Pernyataan dengan diagram panah";
gotoxy(23,7);cout << "B. Hubungan anatar beberapa bilangan dan himpunan";
gotoxy(23,8);cout << "C. Hubungan Antara Dua Anggota Himpunan";
comp='C';comp2='c';
}
else if(i==18)
{
gotoxy(23,5);cout << "Rumus untuk Gradien? ";
gotoxy(23,6);cout << "A. M=Y/X";
gotoxy(23,7);cout << "B. M=T/L";
gotoxy(23,8);cout << "C. M=P/L";
comp='A';comp2='a';
}
else if(i==19)
{
gotoxy(23,5);cout << "berapa hasil dari 2x-y=6 ";
gotoxy(23,6);cout << "A. x = 4";
gotoxy(23,7);cout << "B. x = 3";
gotoxy(23,8);cout << "C. x = 8";
comp='B';comp2='b';
}
else if(i==20)
{
gotoxy(23,5);cout << "Perbandingan Atau Skala dari8/12 cm? ";
gotoxy(23,6);cout << "A. 1 : 3";
gotoxy(23,7);cout << "B. 1 : 9";
gotoxy(23,8);cout << "C. 1 : 2";
comp='C';comp2='c';
}
else if(i==21)
{
gotoxy(23,5);cout << "Satuan dari Panjang ";
gotoxy(23,6);cout << "A. Kg";
gotoxy(23,7);cout << "B. M";
gotoxy(23,8);cout << "C. Hz";
comp='A';comp2='a';
}
else if(i==22)
{
gotoxy(23,5);cout << "Dimensi Dari Itensitas Cahaya? ";
gotoxy(23,6);cout << "A. M ( Meter )";
gotoxy(23,7);cout << "B. N ( Newton )";
gotoxy(23,8);cout << "C. J ( Joule )";
comp='C';comp2='c';
}
else if(i==23)
{
gotoxy(23,5);cout << "Besaran Dari Molekul ? ";
gotoxy(23,6);cout << "A. Jumlah Zat";
gotoxy(23,7);cout << "B. Kuat Arus";
gotoxy(23,8);cout << "C. Suhu";
comp='A';comp2='a';
}
else if(i==24)
{
gotoxy(23,5);cout << "Jika R adalah Resistansi Listrik dan L Indukasi Listrik, Maka Satuan Dari R/L ? ";
gotoxy(23,6);cout << "A. Ohm";
gotoxy(23,7);cout << "B. Hz";
gotoxy(23,8);cout << "C. S";
comp='B';comp2='b';
}
else if(i==25)
{
gotoxy(23,5);cout << "Energi Kinetik Pesawat 1/12 kali dari energi diamnya, jika c kecepatan cahaya, maka laju pesawat adalah? ";
gotoxy(23,6);cout << "A. 5c/12";
gotoxy(23,7);cout << "B. 5c/13";
gotoxy(23,8);cout << "C. 7c/12";
comp='B';comp2='b';
}
else if(i==26)
{
gotoxy(23,5);cout << "M.G.H Dimensi dari Besaran apa? ";
gotoxy(23,6);cout << "A. Usaha";
gotoxy(23,7);cout << "B. Cahaya";
gotoxy(23,8);cout << "C. Energi Potensial";
comp='C';comp2='c';
}
else if(i==27)
{
gotoxy(23,5);cout << "Rumus Dari Vektor Sejajar Dan Searah ";
gotoxy(23,6);cout << "A. R= A + B";
gotoxy(23,7);cout << "B. R= A + (-B)";
gotoxy(23,8);cout << "C. A= B - R";
comp='A';comp2='a';
}
else if(i==28)
{
gotoxy(23,5);cout << "Sin dari 360*? ";
gotoxy(23,6);cout << "A. 4";
gotoxy(23,7);cout << "B. 0";
gotoxy(23,8);cout << "C. 6";
comp='B';comp2='b';
}
else if(i==29)
{
gotoxy(23,5);cout << "Dibawah ini Yang termasuk Resultan? ";
gotoxy(23,6);cout << "A. Vektor ";
gotoxy(23,7);cout << "B. Dimensi";
gotoxy(23,8);cout << "C. GLBB";
comp='A';comp2='a';
}
else if(i==30)
{
gotoxy(23,5);cout << "Dimensi Dari Waktu? ";
gotoxy(23,6);cout << "A. L ( Luas )";
gotoxy(23,7);cout << "B. M ( Meter )";
gotoxy(23,8);cout << "C. T ( Tan )";
comp='C';comp2='c';
}
gotoxy(20,10);
cout << "Jawaban [A/B/C] ";cin >> x;
if(x == comp || x == comp2)
{
p = 'y';
skor = skor+100;
}
else
{
p = 'n';
}
i++;
if(i > 30)
{
p = 'n';
}
// clrscr();
system("cls");
for(int a = 20;a < 60;a++)
{
gotoxy(a,1);cout << "=";
gotoxy(a,3);cout << "-";
gotoxy(a,5);cout << "=";
}
if(i > 30)
{
gotoxy(32,2);cout << "Permainan Selesai \n";
gotoxy(34,4);cout << "Skor = " << skor;
}
else
{
gotoxy(36,2);cout << "Game Over";
gotoxy(35,4);cout << "skor = " << skor;
}
}
}