• Welcome to TUKE FÓRUM - Fórum pre študentov Technickej Univerzity v Košiciach.
 
Menu

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.

Zobrazi� pr�spevky Menu

Messages - profesionale

#1
2. ročník / Re: matematika 1 opakujuci
11.11.2010, 04:12:50
Co ma byt na zapoctovke? z coho? a chcem sy spatat...bude aj opravak...ked ano tak kedy?
#2
A vies mi povedat ako ta gramatika ma vyzerat....lebo akosi som vtedy na prednaske ani na cviku nebol kvoli zdravotnym problemom a nikde o tej gramatike neviem zohnat prezentacie.
#3
Quote from: ursus on  07.11.2010, 22:43:49
Quote from: profesionale on  07.11.2010, 18:54:48
Moje zadanie


* - Do lava -priorita 2   
/ - Do prava - priorita 1

Mozem poprosit o kontrolu ci je to takto spravne. Dakujem

// Interpretator vyrazov s gramatikou
// Expr -> Term { ( <*> | </> ) Term }
// Term -> <Value> | <(> Expr <)>
//
// Pozn: Terminalne symboly su v zatvorkach < >

int expr();



int term()
{ int value;
switch (symbol)
{
case LPAR : getsymbol(); value = expr(); getsymbol(); break;
case VALUE: value = attr; getsymbol(); break;
}
return value;
}

int expr()
{ int leftOp, rightOp; SymType sy;
leftOp = term();
while ((E symbol) & (E DELENIE | E NASOBENIE))
{
sy = symbol; getsymbol(); rightOp = term();
switch (sy)
{
case DELENIE :  leftOp = leftOp / rightOp ; break;
case NASOBENIE:  leftOp = rightOp * leftOp ; break;
}
}
return leftOp;
}


asociativity som nekukal, ale uz len z toho ze mas rozdielne priority nemozes mat obe operatory v jednej funkcii,



A ako to spravit? Vies mi to vystvelit prosim ta....?
#4
Moje zadanie


* - Do lava -priorita 2   
/ - Do prava - priorita 1

Mozem poprosit o kontrolu ci je to takto spravne. Dakujem

// Interpretator vyrazov s gramatikou
// Expr -> Term { ( <*> | </> ) Term }
// Term -> <Value> | <(> Expr <)>
//
// Pozn: Terminalne symboly su v zatvorkach < >

int expr();



int term()
{ int value;
switch (symbol)
{
case LPAR : getsymbol(); value = expr(); getsymbol(); break;
case VALUE: value = attr; getsymbol(); break;
}
return value;
}

int expr()
{ int leftOp, rightOp; SymType sy;
leftOp = term();
while ((E symbol) & (E DELENIE | E NASOBENIE))
{
sy = symbol; getsymbol(); rightOp = term();
switch (sy)
{
case DELENIE :  leftOp = leftOp / rightOp ; break;
case NASOBENIE:  leftOp = rightOp * leftOp ; break;
}
}
return leftOp;
}
#5
Co vlastne treba robit na tom zadani? Co tam doprogramovat alebo co??? Lebo ja tomu zadaniu zadania akosi nechapem.
#6
Ako ma vzerat dokumentacia ????? Prosim o nejaky nahlad. Dakujem
#7
Nema niekto hotove zadanie z cvika 3? Dakujem
#8
1. ro?ník / Re: PPI
26.05.2010, 01:05:50
Ja este vysledok v maise este ani nemam :D A to uz je 7 hodin vecer :D
#9
Chcem sa spýtať. Ked mám zadanie spravené tak že sa skladá zo 6tich funkciíí tak teraz možem spraviť pre každú funkciu vyvojový diagram a nakonci spravit jeden celkovy?? alebo ako??
#10
Zdravim vas. Potreboval by som pomoc s tym ncurses. Farbi vsetko ako ma ale zmeni dana vec pozziciu do vrchneho laveho rohu a posuva sa to do prava. Ked je koniec riadku tak do noveho......netreba tam dat nejaku atributu na fixnu poziciu alebo nieco take??

Dakujem za kazdu radu.

Kod vyzera takto:
void draw() //funkcia na vykreslenie sveta
{
start_color();
    init_pair(COLOR_CYAN, COLOR_CYAN, COLOR_BLACK);
//nastavenie podla OS na ktorom je program spusteny
#ifdef _WIN32
system("cls"); //pre OS Windows
#else
     system("clear"); //pre ostatne OS
#endif

    int i, j;    //definovanie premennych i a j
drawStatus();
    attrset(COLOR_PAIR(COLOR_CYAN)); //zobrzenie informacii o svete a pohyboch karla
    printw("+");
    for(i=0; i<3*world.width; i++)


    printw("-");                                              //vykreslovanie sveta podla danych hodnot sveta
printw("+\n");

    for(i=world.height-1; i>=0; i--) //vytvaranie sveta po osi y
{                 
printw("|");
for(j=0; j<world.width; j++) //vytvaranie sveta po osi x
{ //ked je 0<world.width tak k j pripocitam +1 az dovtedy pokial
printw(" ");        //j nenabudne rovnaku hodnotu ako world.width
                 if(i == karel.y && j == karel.x)
                 {
                      switch(karel.direction) //vykreslenie orientacie karla podla hodnoty v karel.direction
                      {
                          case 0: //ak je karel.direction = 0 vykresli sa >
                               printw(">");
                               break;
                          case 90: //ak je karel.direction = 90 vykresli sa ^
                               printw("^");
                               break;
                          case 180: //ak je karel.direction = 180 vykresli sa <
                               printw("<");
                               break;
                          case 270: //ak je karel.direction = 270 vykresli sa v
                               printw("v");
                               break;
                      }
                 }
                 else if(world.data[i][j] == EMPTY) //ak je hodnota na suradniciach [x,y] 0 vykresli .
                 {
                     printw(".");
                 }
                 else if(world.data[i][j] == WALL) //ak je hodnota na suradniciach [x,y] -1 hodnota vykresli #
                 {
                     printw("#");
                 }
                 else //inak vykresli hodnotu na suradniciach [x,y]
                 {
                     printw("%d", world.data[i][j]);
                 }
 
printw(" ");
    }
printw("|\n");
  }
printw("+"); //ukoncenie sveta - spodna stena
    for(i=0; i<3*world.width; i++) printw("-");
    printw("+\n");
    setStepDelay(200);
    refresh(); //nastavenie rychlosti krokov karla
}
#11
1. ro?ník / Re: Assembler - test
13.05.2010, 05:03:23
Z coho sa ucite? Z prednasok?
#12
Quote from: Maroshv on  11.05.2010, 23:31:32
  [Linker error] undefined reference to `usleep'
  [Linker error] undefined reference to `WinMain@16'
  ld returned 1 exit status

stále nejaka chyba, jednu chybu odstranim, a objaví sa dalšia a nakoniec toto :(

prosím pomôžte, najlepšie cez ICQ 262322023, pošlem zdrojak :)
No ja sa bojim ze to asi nedas dokopy....lebo usleep je to iste ako sleep ale s tym rozdielom ze uslep je na unix. Pri windows sa do sleep udavaju ms tak pri unixe su to sekundy.
#13
cize z main je include iba na library.h z library.c volanie na library.h nieje a teraz mi ta posahana omega hadze toto:

./library.c: In function âturnOnâ:
./library.c:15: error: âkarelâ undeclared (first use in this function)
./library.c:15: error: (Each undeclared identifier is reported only once
./library.c:15: error: for each function it appears in.)
./library.c:17: error: âworldâ undeclared (first use in this function)
./library.c: In function âturnOnFileâ:
./library.c:29: warning: implicit declaration of function âreadWorldFileâ
./library.c: In function âsaveFileâ:
./library.c:34: warning: implicit declaration of function âwriteWorldFileâ
./library.c: In function âdrawâ:
./library.c:48: warning: implicit declaration of function âdrawStatusâ
./library.c:51: error: âworldâ undeclared (first use in this function)
./library.c:61: error: âkarelâ undeclared (first use in this function)
./library.c:79: error: âEMPTYâ undeclared (first use in this function)
./library.c:83: error: âWALLâ undeclared (first use in this function)
./library.c:89: error: âbeepSâ undeclared (first use in this function)
./library.c:106: warning: implicit declaration of function âusleepâ
./library.c: At top level:
./library.c:110: warning: conflicting types for âdrawStatusâ
./library.c:48: warning: previous implicit declaration of âdrawStatusâ was here
./library.c: In function âdrawStatusâ:
./library.c:114: error: âkarelâ undeclared (first use in this function)
./library.c:114: warning: implicit declaration of function âsmerâ
./library.c:114: warning: implicit declaration of function â_beepersAtCurrentPositionâ
./library.c:114: warning: format â%sâ expects type âchar *â, but argument 4 has type âintâ
./library.c: In function âturnLeftâ:
./library.c:124: error: âkarelâ undeclared (first use in this function)
./library.c: In function âturnRightâ:
./library.c:130: error: âkarelâ undeclared (first use in this function)
./library.c: In function âturnBackâ:
./library.c:137: error: âkarelâ undeclared (first use in this function)
./library.c: In function âfrontIsClearâ:
./library.c:149: error: âkarelâ undeclared (first use in this function)
./library.c:153: error: âworldâ undeclared (first use in this function)
./library.c:153: error: âWALLâ undeclared (first use in this function)
./library.c: In function âleftIsClearâ:
./library.c:206: error: âkarelâ undeclared (first use in this function)
./library.c:210: error: âworldâ undeclared (first use in this function)
./library.c:210: error: âWALLâ undeclared (first use in this function)
./library.c: In function ârightIsClearâ:
./library.c:262: error: âkarelâ undeclared (first use in this function)
./library.c:266: error: âworldâ undeclared (first use in this function)
./library.c:266: error: âWALLâ undeclared (first use in this function)
./library.c: In function âfacingSouthâ:
./library.c:320: error: âkarelâ undeclared (first use in this function)
./library.c: In function âfacingNorthâ:
./library.c:332: error: âkarelâ undeclared (first use in this function)
./library.c: In function âfacingWestâ:
./library.c:344: error: âkarelâ undeclared (first use in this function)
./library.c: In function âfacingEastâ:
./library.c:356: error: âkarelâ undeclared (first use in this function)
./library.c: In function âbeepersInBagâ:
./library.c:368: error: âkarelâ undeclared (first use in this function)
./library.c: In function âbeepersPresentâ:
./library.c:385: error: âworldâ undeclared (first use in this function)
./library.c:385: error: âkarelâ undeclared (first use in this function)
./library.c: In function âputBeeperâ:
./library.c:391: error: âworldâ undeclared (first use in this function)
./library.c:391: error: âkarelâ undeclared (first use in this function)
./library.c: In function âpickBeeperâ:
./library.c:402: error: âworldâ undeclared (first use in this function)
./library.c:402: error: âkarelâ undeclared (first use in this function)
./library.c: In function â_beepersAtCurrentPositionâ:
./library.c:411: error: âworldâ undeclared (first use in this function)
./library.c:411: error: âkarelâ undeclared (first use in this function)
./library.c: In function âmovekâ:
./library.c:422: error: âkarelâ undeclared (first use in this function)
./library.c: At top level:
./library.c:446: error: conflicting types for âsmerâ
./library.c:114: error: previous implicit declaration of âsmerâ was here
./library.c:489: warning: conflicting types for âreadWorldFileâ
./library.c:29: warning: previous implicit declaration of âreadWorldFileâ was here
./library.c: In function âreadWorldFileâ:
./library.c:501: error: âworldâ undeclared (first use in this function)
./library.c:501: error: âkarelâ undeclared (first use in this function)
./library.c:508: error: âMAX_WIDTHâ undeclared (first use in this function)
./library.c:508: error: âMAX_HEIGHTâ undeclared (first use in this function)
./library.c:525: error: âWALLâ undeclared (first use in this function)
./library.c: At top level:
./library.c:536: warning: conflicting types for âwriteWorldFileâ
./library.c:34: warning: previous implicit declaration of âwriteWorldFileâ was here
./library.c: In function âwriteWorldFileâ:
./library.c:539: error: âworldâ undeclared (first use in this function)
./library.c:539: error: âkarelâ undeclared (first use in this function)
./library.c:543: error: âWALLâ undeclared (first use in this function)
make: *** [library.o] Error 1

library.h
#ifndef LIBRARY_H
#define LIBRARY_H

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

#define MAX_HEIGHT 20
#define MAX_WIDTH 20
#define WALL -1
#define EMPTY 0

#define EAST 0
#define NORTH 90
#define WEST 180
#define SOUTH 270


char * smer();

enum Boolean {
     False = 0,
     True = 1
};

struct Robot {
    int x;
    int y;
    int beepers;
int direction;   
};
struct Robot karel;


struct World {
  int width, height;
  int data[MAX_HEIGHT][MAX_WIDTH];
};

// World 'world' - global variable
struct World world;


void drawStatus();


// Saves world to file output.kw.
// File will be rewritten if exists.
void turnOff();

// Draws world to standard output.
void draw();

// Draws information about world to standard output.
void drawStatus();


// Returns false if in front of robot is wall or is
// out of map.
int frontIsClear();

// Negation of frontIsClear()
int frontIsBlocked();

// Returns false if left to the robot is wall or is
// out of map.
int leftIsClear();

// Negation of leftIsClear()
int leftIsBlocked();

// See leftIsClear().
int rightIsClear();

// Negation of rightIsClear()
int rightIsBlocked();

// Returns true if there are any beepers in the bag.
int beepersInBag();

// Returns true if there are no beepers in the bag.
int noBeepersInBag();


// Returns count of beepers at current position.
int _beepersAtCurrentPosition();

// Returns robot's direction as string.
char * smer();

// Converts (int) direction to character, like N, S, E, W.
char directionToWord(int direction);

// Loads world from file specified by path parameter.
void readWorldFile(char *path);

// Saves current world to file specified by path parameter.
void writeWorldFile(char *path);
#endif

Pokial som to pochopil tak netaha define.vsetko ostatne natiahne. Teraz nechapem. Ako programujem weby a vzdy som si myslel ze najhorise je spravit kompatibilitu pre IE, Firefox, Safari a podobne....ale vidim ze som sa zmylil.....omega prekonala....
#14
prosim ta a co tam mam zle....mohol by si mi s tym pomost. Prosim ta.
#15
tak teraz mi zase vypisalo toto

In file included from ./main.c:5:
./library.h: At top level:
./library.h:10: error: redefinition of âkarel_beepersâ
./library.h:10: error: previous definition of âkarel_beepersâ was here
./library.h:11: error: redefinition of âkarel_directionâ
./library.h:11: error: previous definition of âkarel_directionâ was here
./library.h:12: error: redefinition of âbeepSâ
./library.h:12: error: previous definition of âbeepSâ was here
./library.h:19: error: nested redefinition of âenum Directionâ
./library.h:19: error: redeclaration of âenum Directionâ
./library.h:20: error: redeclaration of enumerator âEASTâ
./library.h:20: error: previous definition of âEASTâ was here
./library.h:21: error: redeclaration of enumerator âWESTâ
./library.h:21: error: previous definition of âWESTâ was here
./library.h:22: error: redeclaration of enumerator âNORTHâ
./library.h:22: error: previous definition of âNORTHâ was here
./library.h:24: error: redeclaration of enumerator âSOUTHâ
./library.h:24: error: previous definition of âSOUTHâ was here
./library.h:26: error: nested redefinition of âenum Booleanâ
./library.h:26: error: redeclaration of âenum Booleanâ
./library.h:27: error: redeclaration of enumerator âFalseâ
./library.h:27: error: previous definition of âFalseâ was here
./library.h:29: error: redeclaration of enumerator âTrueâ
./library.h:29: error: previous definition of âTrueâ was here
./library.h:32: error: redefinition of âstruct Robotâ
./library.h:40: error: redefinition of âstruct Worldâ

a moj library.h vyzera takto
#include <stdio.h>
#include <stdlib.h>

#define MAX_HEIGHT 20
#define MAX_WIDTH 20
#define WALL -1
#define EMPTY 0


int karel_beepers = 20;
int karel_direction = 0;
int beepS = 1;

char * smer();


// aktualna poloha robota
//enum Direction
enum Direction {
     EAST = 0,
     WEST = 180,
     NORTH = 90,
     SOUTH = 270
};

enum Boolean {
     False = 0,
     True = 1
};

//struktura Robot
struct Robot {
       int x;
       int y;
       int beepers;
       
};
struct Robot karel;

struct World {
  int width, height;
  int data[MAX_HEIGHT][MAX_WIDTH];
};

#16
Mam problem pri kompilovani na omege.

Ked dam skompilovat tak mi vypise zopar warningov.

Napr:

./main.c:27: warning: implicit declaration of function âfacingEastâ

a tomto riadku mam
if(facingEast())
{
int turnBack();
}
else if(facingSouth())
{
int turnRight();
}
else if(facingNorth())
{
int turnLeft();
}
if(!frontIsClear())
{
turnLeft();
while(frontIsClear())
movek();
turnLeft();
}
else
{
while(frontIsClear())
movek();
turnLeft();
movek();
while(frontIsClear())
movek();
turnLeft();
movek();

}
}


definovanie funkcie je tu
int facingSouth()
{
  if (karel_direction == 270) return 1;
    else return 0;
}


Neviete nahodu co ta chyba znamena lebo nikde to neviem najst. Dakujem
#17
pomocou akeho prikazu spustit vykompilovany program cez omegu?
#18
Mam taky problem. Karel poziciu ma poziciu 0,0 v lavom hornom rohu a ja by som chcel dolny lavy...ako to spravit...ja si uz z to karla vytrham vlasy.

void turnOn()
{
    int world1[5][4] = {
   { 1, 1, 2, 3 },
   { 0, 4, 3, 1 },
   { 2, 0, 0, 2 },
   { 5, 1, 0, 3 },
   { 0, 0, 0, 0 }

};
world.width = 4;
world.height = 5;

karel.x = 2;
karel.y = 3;
int x, y;
for(x=0; x<world.height; x++){
for(y=0; y<world.width; y++)
world.data[x][y]=world1[x][y];
}
}




void draw()
{
 system("cls");
 drawStatus();

    int x,y;

    for(x=0; x<world.height; x++)
    {
       for(y=0; y<world.width; y++)
       {

                if(x == karel.y && y == karel.x)
                {
                     switch(karel_direction)
                     {
                         case 0:
                              printf(">");
                              break;
                         case 90:
                              printf("v");
                              break;
                         case 180:
                              printf("<");
                              break;
                         case 270:
                              printf("^");
                              break;
                     }
                }
                else if(world.data[x][y] == EMPTY)
                {
                    printf(".");
                }
                else if(world.data[x][y] == WALL)
                {
                    printf("#");
                }
                else
                {
                    if(beepS == 1)
                    {
                    printf("%d", world.data[x][y]);                              
                    }
                    else
                    {
                    printf("*");                        
                    }
                }
          }
          printf("\n");
    }
   
    printf("\n");
 sleep(1000);    

}
#19
Moze byt senzor facingSouth() takto?


int facingSouth()
{
  if (karel_direction == 0) return 1;
    else return 0;
}


karel direction mam zadane aktualny smer karla v uhloch....cize 0 90 180 270

Dakujem
#20
Quote from: mirek on  05.05.2010, 17:19:24
Quote from: Bc. nemtom on  05.05.2010, 17:11:52
iba z nazvu funkcii usudzujem ze zistuje na aku svetovu stranu sa pozera karel ci sipka ci co to tam mate
presne tak. dokonca aj google hodi pomerne dobry preklad: "ak Karel stojí na východ"

Ale naco mam spravit funkciu na senzor na aky smer smeruje ked to mi ukazuje priamo ked zapnem karla a zacne sa pohybovat. Tak potom naco senzor na svetove strany?
#21
Caute. Chcem sa spytat na senzori facingSouth() , facingWest() .... o co ide pri tychto senzoroch....lebo neviem ci som si to spravne z anglictiny prelozil. Ma to znamenat ci je na SEVER, JUH, ZAPAD, VYCHOD stena alebo ako???


Dakujem za odpoved.
#22
1. ročník / Re: ZIM
13.02.2007, 18:40:27
Cawte.Chcem sa spytat ze ked pojdem do inej miestnosti pocas opravnej ci mi nieco mozu.Lebo mam byt v miestnosti P27 a tam sa nahovno pouziva tahak...a preto chcem ist do AF.Mozem mat z toho nejake problemy alebo je to jedno??