Wednesday, 9 November 2011

Simple game Tower of Hanoi for C languange

This is the second file...lol ^^
and it is more easy than the tic tac toe game....

enjoy and try it at your computer...^^8

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

void main()
{
void hanoi(int n,char tower1,char tower3,char tower2);
char tower1='A',tower2='B',tower3='C';
int n;

printf("\n WELCOME TO TOWER OF HANOI SIMULATION\t\t\tby:Ridwan ^^v \n\n ");
printf("---------------------------------------------------\n");
printf("We'll help you to finish the tower of hanoi game only several second\n");
printf("Please Enjoy it\n");
printf("====================================================\n");

printf(" Enter the summary of disk on A : "); scanf("%d",&n);
puts("");
if(n<1)
{
printf(" Nothing to move. The disk must only or more than 1! ^^v \n");
}

hanoi(n, tower1, tower3, tower2);
getch();
}

void hanoi(int n,char tower1,char tower3,char tower2)
{

if(n==1)
{
printf(" Move the disk no 1 from %c to %c\n",tower1,tower3);
return;
}
else

hanoi(n-1,tower1,tower2,tower3);
printf(" Move the disk no %d from %c to %c\n",n,tower1,tower3);
hanoi(n-1,tower2,tower3,tower1);
}



more easy right? but it still confusing my head when I'm in the first year of college...lol ^^

Simple tic tac toe game

After open a folder in my Dynabook laptop, I found some file that were saved in my lost laptop ( Acer ) two years ago because of stolen. Yeah, it is a simple program that I was learn it in fisrt year of college.

I write it here so we can refresh our mind after learning about Android (wow!! sound's amazing! lol )
Before learning more about Android, is better you read this one first..hehehe ^^

check it out guys!



#include <stdio.h>

#include <>

#include 
#include 

struct list
{
int no;
char matrix[1];
struct list *next;
struct list *prev;
} *head, *tail, *temp;

int random()
srand((unsigned) time(0));
return(rand()%10);
}


void main()
{
int i,j=50,acak=5,jawab;
char strjawab[1];

printf(" Welcome to Tic Tac Toe Game\t\t\t by: Ridwan\n");
printf(" Your opponent is computer\n");
printf(" Good Luck and enjoy\n\n");
//buat head
head=(struct list*)malloc(sizeof(struct list));
head->no=1;
head->matrix[0]=NULL;
head->next=NULL;
head->prev=NULL;
temp=head;
//buat tail dan temporary
for (i=2;i<=9;i++)
{
tail=(struct list*)malloc(sizeof(struct list));
tail->no=i;
tail->matrix[0]=NULL;
temp->next=tail;
temp->prev=temp;
tail->next=NULL;
temp=tail;
j++;
}
//data awal
temp=head;
i=1;

while(temp!=NULL)
{
if(temp->matrix[0]==NULL)
printf("\t|"/*,temp->no*/);
else 
printf("\t%c",temp->matrix[0]);
if(i==3||i==6)
printf("\n");
temp=temp->next;
i++;
}
//printf("\n\n Player\t= O");
//printf("\n Computer\t= X");
printf("\n Do you wanna play now?=");
gets(strjawab);

while(1)
if (strcmp(strjawab,"y")==0)
start: system("cls");
puts("");
temp=head;
i=1;

while(temp!=NULL)
{
if(temp->matrix[0]==NULL)
printf("\t|"/*,temp->no*/);
else 
printf("\t%c",temp->matrix[0]);
if(i==3||i==6)
printf("\n");
temp=temp->next;
i++;
}
player:
printf("\n\n where do you wanna go?");
gets(strjawab);
jawab=atoi(strjawab);
temp=head;

while(temp!=NULL)
if(jawab>=1&&jawab<=9)
{
if(temp->no==jawab)
{
if(temp->matrix[0]==NULL)
strcpy(temp->matrix,"O");
else 
{
printf(" Number %d is not empty",temp->no);
goto player;
}
}
temp=temp->next;
}
else
{
printf(" Insert number 1 until 9");
goto player;
}

}

system("cls");
puts("");
temp=head;
i=1;

while(temp!=NULL)
{
if(temp->matrix[0]==NULL)
printf("\t|"/*,temp->no*/);
else 
printf("\t%c",temp->matrix[0]);
if(i==3||i==6)
printf("\n");
temp=temp->next;
i++;
}

printf("\n\n Player go to number\t=%d",jawab);
printf("\n Loading...");
getche();


//membentuk baris horizontal
temp=head;
if(strcmp(temp->matrix,"O")==0&&strcmp(temp->next->matrix,"O")==0&&strcmp(temp->next->next->matrix,"O")==0)
{
printf("\n\n Player win...\n");break;
}
else if(strcmp(temp->matrix,"X")==0&&strcmp(temp->next->matrix,"X")==0&&strcmp(temp->next->next->matrix,"X")==0)
{
printf("\n\n Computer win...\n");break;
}

temp=head->next->next->next;
if(strcmp(temp->matrix,"O")==0&&strcmp(temp->next->matrix,"O")==0&&strcmp(temp->next->next->matrix,"O")==0)
{
printf("\n\n Player win...\n");break;
}
else if(strcmp(temp->matrix,"X")==0&&strcmp(temp->next->matrix,"X")==0&&strcmp(temp->next->next->matrix,"X")==0)
{
printf("\n\n Computer win...\n");break;
}

temp=head->next->next->next->next->next->next;
if(strcmp(temp->matrix,"O")==0&&strcmp(temp->next->matrix,"O")==0&&strcmp(temp->next->next->matrix,"O")==0)
{
printf("\n\n Player win...\n\n");break;
}
else if(strcmp(temp->matrix,"X")==0&&strcmp(temp->next->matrix,"X")==0&&strcmp(temp->next->next->matrix,"X")==0)
{
printf("\n\n Computer win...\n\n");break;
}

//membentuk baris vertikal
temp=head;
if(strcmp(temp->matrix,"O")==0&&strcmp(temp->next->next->next->matrix,"O")==0&&strcmp(temp->next->next->next->next->next->next->matrix,"O")==0)
{
printf("\n\n Player win...\n");break;
else if(strcmp(temp->matrix,"X")==0&&strcmp(temp->next->next->next->matrix,"X")==0&&strcmp(temp->next->next->next->next->next->next->matrix,"X")==0)
{
printf("\n\n Computer win...\n");break;
}

temp=head->next;
if(strcmp(temp->matrix,"O")==0&&strcmp(temp->next->next->next->matrix,"O")==0&&strcmp(temp->next->next->next->next->next->next->matrix,"O")==0)
{
printf("\n\n Player win...\n");break;
}
else if(strcmp(temp->matrix,"X")==0&&strcmp(temp->next->next->next->matrix,"X")==0&&strcmp(temp->next->next->next->next->next->next->matrix,"X")==0)
{
printf("\n\n Computer win...\n");break;
}

temp=head->next->next;
if(strcmp(temp->matrix,"O")==0&&strcmp(temp->next->next->next->matrix,"O")==0&&strcmp(temp->next->next->next->next->next->next->matrix,"O")==0)
{
printf("\n\n Player win...\n");break;
}
else if(strcmp(temp->matrix,"X")==0&&strcmp(temp->next->next->next->matrix,"X")==0&&strcmp(temp->next->next->next->next->next->next->matrix,"X")==0)
{
printf("\n\n Computer win...\n");break;
}

//membentuk diagonal
temp=head;
if(strcmp(temp->matrix,"O")==0&&strcmp(temp->next->next->next->next->matrix,"O")==0&&strcmp(temp->next->next->next->next->next->next->next->next->matrix,"O")==0)
{
printf("\n\n Player win...\n");break;
}
else if(strcmp(temp->matrix,"X")==0&&strcmp(temp->next->next->next->next->matrix,"X")==0&&strcmp(temp->next->next->next->next->next->next->next->next->matrix,"X")==0)
{
printf("\n\n Computer win...\n");break;
}

temp=head->next->next;
if(strcmp(temp->matrix,"O")==0&&strcmp(temp->next->next->matrix,"O")==0&&strcmp(temp->next->next->next->next->matrix,"O")==0)
{
printf("\n\n Player win...\n");break;
}
if(strcmp(temp->matrix,"X")==0&&strcmp(temp->next->next->matrix,"X")==0&&strcmp(temp->next->next->next->next->matrix,"X")==0)
{
printf("\n\n Computer win...\n");break;
}


temp=head;
while(temp!=NULL)
{
if(temp->no==acak)
{
if(temp->matrix[0]==NULL)
strcpy(temp->matrix,"X");
else 
goto computer;
}
temp=temp->next;
}
goto shortcut1;




computer: 
acak=random(); 
temp=head;

while(temp!=NULL)
if(acak==0)
goto computer;
else
{
if(temp->no==acak)
{
if(temp->matrix[0]==NULL)
strcpy(temp->matrix,"X");
else 
goto computer;
}
}
temp=temp->next;
}

shortcut1: 
system("cls");
puts("");
temp=head;
i=1;


while(temp!=NULL)
{
if(temp->matrix[0]==NULL)
printf("\t|"/*,temp->no*/);
else 
printf("\t%c",temp->matrix[0]);
if(i==3||i==6)
printf("\n");
temp=temp->next;
i++;
}

printf("\n\n Player go to number\t=%d",jawab);
printf("\n Computer go to number\t=%d",acak);
printf("\n Loading...");
getche();

//membentuk baris horizontal
temp=head;
if(strcmp(temp->matrix,"O")==0&&strcmp(temp->next->matrix,"O")==0&&strcmp(temp->next->next->matrix,"O")==0)
{
printf("\n\n You win...\n");break;
}
else if(strcmp(temp->matrix,"X")==0&&strcmp(temp->next->matrix,"X")==0&&strcmp(temp->next->next->matrix,"X")==0)
{
printf("\n\n Computer win...\n");break;
}

temp=head->next->next->next;
if(strcmp(temp->matrix,"O")==0&&strcmp(temp->next->matrix,"O")==0&&strcmp(temp->next->next->matrix,"O")==0)
{
printf("\n\n Player win...\n");break;
}
else if(strcmp(temp->matrix,"X")==0&&strcmp(temp->next->matrix,"X")==0&&strcmp(temp->next->next->matrix,"X")==0)
{
printf("\n\n Computer win...\n");break;
}

temp=head->next->next->next->next->next->next;
if(strcmp(temp->matrix,"O")==0&&strcmp(temp->next->matrix,"O")==0&&strcmp(temp->next->next->matrix,"O")==0)
{
printf("\n\n Player win...\n\n");break;
}
else if(strcmp(temp->matrix,"X")==0&&strcmp(temp->next->matrix,"X")==0&&strcmp(temp->next->next->matrix,"X")==0)
{
printf("\n\n Computer win...\n\n");break;
}

//membentuk baris vertikal
temp=head;
if(strcmp(temp->matrix,"O")==0&&strcmp(temp->next->next->next->matrix,"O")==0&&strcmp(temp->next->next->next->next->next->next->matrix,"O")==0)
{
printf("\n\n Player win...\n");break;
else if(strcmp(temp->matrix,"X")==0&&strcmp(temp->next->next->next->matrix,"X")==0&&strcmp(temp->next->next->next->next->next->next->matrix,"X")==0)
{
printf("\n\n Computer win...\n");break;
}

temp=head->next;
if(strcmp(temp->matrix,"O")==0&&strcmp(temp->next->next->next->matrix,"O")==0&&strcmp(temp->next->next->next->next->next->next->matrix,"O")==0)
{
printf("\n\n Player win...\n");break;
}
else if(strcmp(temp->matrix,"X")==0&&strcmp(temp->next->next->next->matrix,"X")==0&&strcmp(temp->next->next->next->next->next->next->matrix,"X")==0)
{
printf("\n\n Computer win...\n");break;
}

temp=head->next->next;
if(strcmp(temp->matrix,"O")==0&&strcmp(temp->next->next->next->matrix,"O")==0&&strcmp(temp->next->next->next->next->next->next->matrix,"O")==0)
{
printf("\n\n Player win...\n");break;
}
else if(strcmp(temp->matrix,"X")==0&&strcmp(temp->next->next->next->matrix,"X")==0&&strcmp(temp->next->next->next->next->next->next->matrix,"X")==0)
{
printf("\n\n Computer win...\n");break;
}

//membentuk diagonal
temp=head;
if(strcmp(temp->matrix,"O")==0&&strcmp(temp->next->next->next->next->matrix,"O")==0&&strcmp(temp->next->next->next->next->next->next->next->next->matrix,"O")==0)
{
printf("\n\n Player win...\n");break;
}
else if(strcmp(temp->matrix,"X")==0&&strcmp(temp->next->next->next->next->matrix,"X")==0&&strcmp(temp->next->next->next->next->next->next->next->next->matrix,"X")==0)
{
printf("\n\n Computer win...\n");break;
}

temp=head->next->next;
if(strcmp(temp->matrix,"O")==0&&strcmp(temp->next->next->matrix,"O")==0&&strcmp(temp->next->next->next->next->matrix,"O")==0)
{
printf("\n\n Player win...\n");break;
}
if(strcmp(temp->matrix,"X")==0&&strcmp(temp->next->next->matrix,"X")==0&&strcmp(temp->next->next->next->next->matrix,"X")==0)
{
printf("\n\n Computer win...\n");break;
}

goto start;
}
}
printf(" Thanks for play the game ^^\n");
getche();
}





It's so confusing is not it?? 
I'm confusing too...lol ^^v

Monday, 7 November 2011

Android Vocabulary

I made this post for us to closer to the Android Operating System because many of the terms used in this case.
Hope it can help you to know more about this Operating System.


APK
APK is Android Package, such as the IPA in the iPhone, SIS on Symbian s60, or JAR on BlackBerry and other devices based on JAVA. Essentially, the file with the extension of  " .apk" can be used to install the application on android device.


Brick(ed)
Device conditions that it can not to recover again. It is like Death Phone. It could be just like a brick that can throw a dog.. ^^v
It can not be used anymore, due to an error when flashing or physical damage.

adb
Command bridge through Android on Personal Computer. There are many command extension for adb such as :
adb shell
adb push
adb install and many more
The requirement conditions of adb is adb tools must be installed in your computer.

adb.exe
can be taken from android sdk folder. the adb.exe was included there in pltform-tools.

adb shell logcat
for knowing the process that occured in your Android. It's very useful when you are doing an experiments of flashing ROM.

root
Is there a person in the world who did not know with this word? They who always use linux know it.
you will get SuperUser application if you are rooting your device.
Is process to change privilage from normal user become root.

Boot
turn on the device process.

Booting
The combine of PL and IPL which became the basis of device.

Recovery Mode
In this mode we can open the shell and flash image or you want to backup or restore your data.

Android Operating System

Now days many people always talking about Android.
What is Android? Why it become so famous? It is an Operating System?
How could he bewitched so many people to use it? Actually, not just for use it but to develop it, to make it become  a briliant creativity...


I will tell what is it and why the Android is become a trendsetter now.. lol :D


Android is an Operating System for mobile phone such as smartphones and tablet computers. It is developed by the OHA ( Open Handset Alliance ) the member is Broadcom corp., HTC, Intel, LG,Marvell Technology Group, Nvidia, Motorolla, Qualcomm, Samsung, T-Mobile, Texas Instrument, ARM Holdings, Atheros, Garmin, Huawei Technologies, Sony Ericsson, Vodafone and so on that led by Google <== the bigger search engines in the world. Amazing!!


Google purchased the initial developer of the software, Android Inc in 2005. The unveiling of the Android distribution on November 5, 2007 was announced with the founding of the OHA.
Android consists of a kernel based on the Linux. Android uses the Dalvik Virtual Machine with just in time compilation to run Dalvik bytecode, which is usually translated from JAVA bytecode. Android has a large community of developers writing applications that extend the functionality of the devices. Developers write primarily in a customized version of Java. There are currently approximately 300,000 apps available for Android, from a total of 500,000 apps over the life of Android. Apps can be downloaded from third-party sites or through online stores the name is Android Market, the app store run by Google.
Android was listed as the best-selling smartphone platform worldwide in Q4 2010. With over 190 million Android devices in use by October 2011.


Why? Because Android is based on Linux kernel which is open source. That's why many people love it...^^