andi

Breaking News
Loading...
Selasa, 11 Desember 2012

contoh penggunaan switch-case C++

17.47
#include <iostream.h>
#include <conio.h>
#include <stdlib.h>

void main()
{
char a=15; short x, y, key1, key2;
for (x=10, y=10;;)
{
clrscr();
gotoxy(x,y);
cout<<a;

key1=getch();
if (key1==0)
{
key2=getch();
switch(key2)
{ case 72: a=30; y--; if (y==0) y=25; break;
case 75: a=17; x--; if (x==0) x=59; break;
case 77: a=16; x++; if (x==60) x=0; break;
case 80: a=31; y++; if (y==26) y=0; break;
default: a=15;
}
}
}
}

0 komentar:

Posting Komentar

 
Toggle Footer