Zobraziť príspevky

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Marek9011

Pages: [1]
1
1. ročník / Re: Programovanie
« on: 26.02.2011, 18:26:11 »
dakujem a ten stred sveta bez pouziatia premennych ma niekto spravené?
najlepsie bude zacat asi od zaciatku preto som si urobil funkciu

Quote
void kustene()
{
if (frontIsClear())
         {movek();}
}

void nazaciatok()
{
if (facingSouth())
   {kustene();turnRight();kustene();turnAround();}
if (facingNorth())
   {turnAround();kustene();turnRight();kustene();turnAround();}
if (facingWest())
   {kustene();turnLeft();kustene();turnLeft();}
if (facingEast())
   {turnAround();kustene();turnLeft();kustene();turnLeft();}
}
...ale dalej uz sa neviem pohnut, vsetky napady si vitane

2
1. ročník / Re: karel-algoritmus
« on: 19.02.2011, 02:45:19 »
...a este by ma zaujimalo ci by nestacila len jedna podmienka

3
1. ročník / karel-algoritmus
« on: 19.02.2011, 02:07:49 »
zdravim,
  • Potreboval by som aby karel robyl nizsie uvedene podmienky automaticky a nie aby som mu to vzdy prikazoval  (teda aby bol program prenositelny na ine svety ...vid priloha)
  • aky je rozdiel ak na zaciatku ked definujem funkcie dam namiesto void int ...na upsku som tak robil a funfuje to


Quote
#include <karel.h>

void turnRight(){   
turnLeft();   
turnLeft();   
turnLeft();}

void turnAround(){    
turnLeft();    
turnLeft();}

void oznac(){    
turnRight();    
movek();    
putBeeper();
turnAround();    
movek();    
turnRight();}




int main(){    
turnOn("road1.kw");
setStepDelay(300);

if (rightIsBlocked())
         {movek();}
     else{oznac();}
    
if (rightIsClear())
       {oznac();movek();}
       else{movek();}

    
  
turnOff();    
return 0;}

Pages: [1]