Archive for the program Alant Junedi.DS Category

wuihhh… game nech…(buka di BC5 mu)

Posted in program Alant Junedi.DS on March 30, 2008 by 4l4nt

#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<stdlib.h>
#include<time.h>

int xp=39,yp=23,xt=1,yt=1,xb=1,yb,yh,hp=3,stg=1,i,cnt=0;
int input,tekan;

void delay(int n) {
int i;

for(i=0; i<n*n*n*5; i++);

}

void loading(int cnt) {
_setcursortype(_NOCURSOR);
clrscr();
textcolor(LIGHTBLUE);
gotoxy(34,8); cprintf(“NOW LOADING”);
textcolor(BROWN);
gotoxy(25,18); cprintf(“==============================”);
gotoxy(24,18); cprintf(“/”);
gotoxy(24,19); cprintf(“|”);
gotoxy(24,20); cprintf(“\\”);
gotoxy(25,20); cprintf(“==============================”);
gotoxy(55,18); cprintf(“\\”);
gotoxy(55,19); cprintf(“|”);
gotoxy(55,20); cprintf(“/”);
textcolor(LIGHTBLUE+BLINK);
gotoxy(31,22); cprintf(“…PLEASE WAIT…”);

for(cnt=0;cnt<30;cnt++) {
textcolor(GREEN);
gotoxy(25+cnt,19); cprintf(“%c”,1);
delay(400);
}
}

void menu(int tekan) {
_setcursortype(_NOCURSOR);
clrscr();
textcolor(CYAN);
gotoxy(2, 6); cprintf(“=== MAIN  MENU ===”);
gotoxy(2, 9); cprintf(“1.   Start Game”);
gotoxy(2,11); cprintf(“2.   View Help”);
gotoxy(2,13); cprintf(“Esc. Quit Game”);
textcolor(CYAN+BLINK);
gotoxy(2,3); cprintf(“WELCOME TO SPACE INVADER”);

tekan=getch();
switch(tekan) {
case’1′ : break;
case’2′ : {
clrscr();
textcolor(GREEN);
gotoxy(2, 2); cprintf(“W     =  Move Up”);
gotoxy(2, 4); cprintf(“S     =  Move Down”);
gotoxy(2, 6); cprintf(“A     =  Move Left”);
gotoxy(2, 8); cprintf(“D     =  Move Right”);
gotoxy(2,10); cprintf(“Enter =  Fire”);
gotoxy(2,13); cprintf(“Esc   =  Quit Game”);
textcolor(GREEN+BLINK);
gotoxy(5,20);
cprintf(“…Press Any Key To Continue…”);
getch();
break;
}
case 27 : exit(10);
}
}

void pesawat(int xp, int yp) {
_setcursortype(_NOCURSOR);
textcolor(RED);
gotoxy(xp,yp-1); cprintf(“*”);
textcolor(LIGHTBLUE);
gotoxy(xp,yp); cprintf(“|”);
gotoxy(xp-1,yp+1); cprintf(“|-|”);
gotoxy(xp-1,yp+2); cprintf(“/ \\”);

}

void gerak(int input) {
_setcursortype(_NOCURSOR);
switch(input) {
case ‘d’ : xp++; break;
case ‘a’ : xp–; break;
case ‘w’ : yp–; break;
case ’s’ : yp++; break;
}
}

void bullet(int xp, int yp) {
_setcursortype(_NOCURSOR);
for(xb=xp,yb=yp-2,yh=yb+1;xb>xt,yb>yt;yb–,yh–) {
gotoxy(xb,yb);
textcolor(RED);
cprintf(“*”);
gotoxy(xb,yh);
printf(” “);
delay(100);
}
}

void kena(int xt, int yt) {
_setcursortype(_NOCURSOR);
hp++;
stg++;
gotoxy(xt,yt);
delay(350);
printf(” “);
printf(“+1 HP”);
delay(350);
}

void main()
{
_setcursortype(_NOCURSOR);
textmode(C80);
loading(cnt);
delay(300);
menu(tekan);
delay(300);
randomize();

do {
fflush(stdin);
xt=random(50)+3;
yt=random(10)+1;

do {
clrscr();
fflush(stdin);
textcolor(YELLOW);
gotoxy(74,22); cprintf(“HP = %d”,hp);
gotoxy(71,24); cprintf(“STAGE = %d”,stg);
pesawat(xp,yp);

if(xp<=2) xp++;
else if(xp>=55) xp–;
else if(yp<=13) yp++;
else if(yp>=22) yp–;

textcolor(LIGHTGREEN);
gotoxy(xt,yt); cprintf(“%c”,2);

input=getch();
gerak(input);

if(input==13) {
bullet(xp,yp);
if(xb==xt && yb==yt) {
kena(xt,yt);
xt=random(50)+3;
yt=random(10)+1;
}
else {
gotoxy(xb,yb-1);
textcolor(LIGHTRED);
cprintf(“-1 HP”);
delay(400);
hp–;
}

}

if(hp==0 || input==27) {
break;
}

if(stg>10) {
break;
}
}
while(input!=27);

clrscr();

if(stg>10) {
textcolor(LIGHTMAGENTA);
gotoxy(30,7); cprintf(“THANK YOU FOR PLAYING”);
getch();
clrscr();
break;
}

else {
textcolor(LIGHTMAGENTA);
gotoxy(36,10); cprintf(“YOU LOSE”);
gotoxy(22,15); cprintf(“DO YOU WANT TO PLAY AGAIN ? … [Y/N]“);
input=getch();
if(input==121) {
clrscr();
hp=3;
stg=1;
continue;
}
else if(input==110) break;

clrscr();
break;
}

}
while(hp>0);
}

“Biner”

Posted in program Alant Junedi.DS on December 18, 2007 by 4l4nt

Input:

11001 1000001

Output:

11001 + 1000001:

Desimal : 25 + 65 = 90

Oktal : 31 + 101 = 132

Heksadesimal : 19 + 41 = 5A

________________________

| “Versi 1″ |

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>

void main()
{
char a[100],b[100],c[100],d[100];
long m,n,o;
int x,y,z;

while(scanf(“%s”,a)!=EOF){
scanf(“%s”,c);
clrscr();
printf(“%s + %s :\n”,a,c);
m=strtol(a,b,2);
n=strtol(c,d,2);
o=m+n;
printf(“Desimal : %d + %d = %d\n”,m,n,o);
printf(“Oktal : %o + %o = %o\n”,m,n,o);
printf(“Heksadesimal : %X + %X = %X\n”,m,n,o);
getch();
}
}

________________________

|”versi 2″|

#include <stdio.h>
#include <conio.h>
#include <math.h>
#include <string.h>
void main()
{
char a[10],b[10];
int c,d;
int e,f;
int i;
while(scanf(“%s%s”,&a,&b)!=EOF)
{
c = 0;
d = 0;
e = 0;
for(i=strlen(a);i>=0;i–)
{
if ( a[i] == ‘1′ ) c = c + (pow(2,e)/2);

e++;
}

e = 0;
for(i=strlen(b);i>=0;i–)
{
if ( b[i] == ‘1′ ) d = d + (pow(2,e)/2);
e++;
}
f = c + d;
printf(“%s + %s :\n”,a,b);
printf(“Decimal %d + %d = %d\n”,c,d,f);
printf(“Oktal %o + %o = %o\n”,c,d,f);
printf(“Hexadecimal %X + %X = %X\n”,c,d,f);
}
}

Reverse

Posted in program Alant Junedi.DS on December 17, 2007 by 4l4nt

Input:

12345

Output:

54321

________________________

#include <stdlib.h>
#include <stdio.h>
#include<conio.h>
#include<string.h>

void main()
{
int number,i,x;
char string[25],l[25];
while(scanf(“%d”,&number)!=EOF){
itoa(number, string, 10);
i=strlen(string);

for(x=0;x<i;x++)
{
l[i-x-1]=string[x];
}

l[i]=string[i];
printf(“%s\n”,l);
}
getch();
}

“Transpose” (“,)

Posted in program Alant Junedi.DS on December 15, 2007 by 4l4nt

Input:

9

5

1

7

5

3

4

5

Output:

9 7 4

5 5 5

1 3 1

________________________

#include<stdio.h>
#include<conio.h>

void main(){
int i;
int angka[9];
while(scanf(“%d”,&angka[0])!=EOF) {
for(i=1;i<8;i++){
scanf(“%d”,&angka[i]);}

printf(“\n%d %d %d\n”,angka[0],angka[3],angka[6]);
printf(“%d %d %d\n”,angka[1],angka[4],angka[7]);
printf(“%d %d %d\n”,angka[2],angka[5],angka[8]);
getch();
}
}

“Ketupat”

Posted in program Alant Junedi.DS on December 15, 2007 by 4l4nt

#include<stdio.h>

void bk(int n) {
int i,j;
for(i=0;i<n+1;i++){
for(j=n;j>i;j–){
printf(” “);}
for(j=1;j<=(2*i+1);j++){
if(j%2==0){ printf(” “);}
if(j%2==1){ printf(“*”);}}
printf(“\n”);}
for(i=0;i<n;i++){
for(j=-1;j<i;j++){
printf(” “);}

for(j=(2*n)+1;j>(2*i)+1;j–){
if(j%2==0){ printf(” “);}
if(j%2==1){ printf(“*”);}}
printf(“\n”);}}
void main() {
int angka,x[6];
while(scanf(“%d”,&angka)!=EOF) {
if(angka >=1 && angka<=1000000) {

do{
x[5]=angka/100000;
x[4]=(angka-(x[5]*100000))/10000;
x[3]=(angka-(x[4]*10000)-(x[5]*100000))/1000;
x[2]=(angka-(x[3]*1000)-(x[4]*10000)-(x[5]*100000))/100;
x[1]=(angka-(x[2]*100)-(x[3]*1000)-(x[4]*10000)-(x[5]*100000))/10;
x[0]=angka%10; angka=x[0]+x[1]+x[2]+x[3]+x[4]+x[5]; }
while(angka>=10);
bk(angka); }}}

Manipulasi String :-P

Posted in program Alant Junedi.DS on December 15, 2007 by 4l4nt

Input:

alant junedi ds

Output:

ALANT JUNEDI DS

alant junedi ds

AlAnT JuNeDi dS

aLaNt jUnEdI Ds

________________________

#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<ctype.h>

void main() {
char kalimat[100];
int i;
clrscr();
gets(kalimat);
printf(“%s\n”, strupr(kalimat));
printf(“%s\n”, strlwr(kalimat));
for(i=0; i<strlen(kalimat); i++) {
if(i%2!=0 && kalimat[i]!=NULL) printf(“%c”, tolower(kalimat[i]));
else printf(“%c”, toupper(kalimat[i]));
}
printf(“\n”);
for(i=0; i<strlen(kalimat); i++) {
if(i%2==0) printf(“%c”, tolower(kalimat[i]));
else printf(“%c”, toupper(kalimat[i]));
}
printf(“\n”);
getch();
}

Deret ganjil dan genap dari suatu angka

Posted in program Alant Junedi.DS on December 15, 2007 by 4l4nt

Input:

10

Output:

genap   : 0 2 4 6 8 10

ganjil    : 1 3 5 7 9

________________________

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;

while(scanf(“%d”,&b)!=EOF)
{
printf(“Genap :”);
for(a=0;a<=b;a++)
{
if(a%2==0)printf(” %d”,a);
}
printf(“\nGanjil :”);
for(c=0;c<=b;c++)
{
if(c%2!=0)printf(” %d”,c);
}
printf(“\n”);
}
}

“ganjil 3n+1, genap n/2″

Posted in program Alant Junedi.DS on December 14, 2007 by 4l4nt

input:

5

8

9

output:

jumlah 3n+1 dari 5

5 16 8 4 2 1

jumlah 3n+1 dari 8

8 4 2 1

jumlah 3n+1 dari 9

9 28 14 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1

_________________________

#include <conio.h>
#include <stdio.h>

void main ()
{

int a,b,c;
scanf(“%d”,&a);
scanf(“%d”,&b);
scanf(“%d”,&c);
printf(“jumlah 3n+1 dari %d\n”,a);
printf(“%d”,a);

do{
if (a%2!=0){
a = 3*a+1;
}
else if(a%2==0){
a= a/2;
}
printf(” %d”,a);
}while (a!=1);

printf(“\n”);
printf(“jumlah 3n+1 dari %d\n”,b);
printf(“%d”,b);

do {
if (b%2!=0){
b = 3*b+1;
}
else if(b%2==0){
b= b/2;
}
printf(” %d”,b);
} while (b!=1);

printf(“\n”);
printf(“jumlah 3n+1 dari %d\n”,c);
printf(“%d”,c);

do {
if (c%2!=0){
c = 3*c+1;
}
else if(c%2==0){
c= c/2;
}
printf(” %d”,c);
} while (c!=1);

getch();

}

Tanda panah

Posted in program Alant Junedi.DS on December 14, 2007 by 4l4nt

input:

masukkan=5

output:

*****

**

* *

* *

* *

_________________________

#include<stdio.h>
#include<conio.h>

void main()
{
int a,b,c,d,e;
printf(“input masukan=”);
scanf(“%d”,&a);

d=2;
e=1;

for(b=1;b<=a;b++)
{
printf(“*”);
}
printf(“\n”);

for(b=1;b<a;b++)
{
for(c=1;c<=a;c++)
{
if(c==d || c==e)
{
printf(“*”);
}
else printf(” “);
}
printf(“\n”);

d=d+1;
}

getch();
}

“Kalkulator cupu alant junedi”

Posted in program Alant Junedi.DS on December 14, 2007 by 4l4nt

#include <stdio.h>
#include <conio.h>
#include <string.h>

void hapus (){
clrscr ();
}

void main (){
int umur;
int tambah1, tambah2, hasiltambah;
int kali1, kali2, hasilkali;
int tekan;
char nama [20];

hapus();
printf (“                       kalkulator cupu ala alant junedi\n”);
do {
gotoxy(1,4);
printf (“masukkan nama anda : “);
clreol (); fflush (stdin);
gets (nama);
} while (strlen (nama) >150);
do {
gotoxy(1,5);
printf (“masukkan umur anda [17+]: “);
clreol ();
fflush (stdin);
scanf (“%d”, &umur);
} while ( umur < 17 );
hapus();

do {
hapus();
gotoxy (1,2);
printf (” selamat datang %s”, nama);
gotoxy (1,3);
printf (” umur : %d “, umur);
gotoxy (1,5);
printf (“PILIH MENU : “);
gotoxy (1,6);
printf (“1. penjumlahan”);
gotoxy (1,7); printf (“2. perkalian”);
gotoxy (1,8); printf (“3. exit”);

tekan=getch();
switch (tekan) {
case ‘1′ : hapus();
gotoxy (2,2);
printf (“masukkan angka pertama = “); scanf (“%d”, &tambah1);
gotoxy (2,3);
printf (“kalo angka kedua = “); scanf (“%d”, &tambah2);
hasiltambah = tambah1 + tambah2;
gotoxy (2,4);
printf (“hasil = %d “, hasiltambah);
getch ();
break;
case ‘2′ : hapus();
gotoxy (2,2);
printf (“masukkan angka pertama = “); scanf (“%d”, &kali1);
gotoxy (2,3);
printf (“masukkan angka kedua = “); scanf (“%d”, &kali2);
gotoxy (2,4);
hasilkali = kali1 * kali2;
printf (“hasil = %d “, hasilkali);
getch();
break; }

} while (tekan !=1 || tekan !=2);
getch();
}