2020-09-29 17:23:12 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2020-09-30 18:31:17 +00:00
|
|
|
#include <ctype.h>
|
|
|
|
#include <stdlib.h>
|
2020-09-29 17:23:12 +00:00
|
|
|
|
|
|
|
#define LINESIZE 100
|
|
|
|
#define LINE_SIZE 100
|
|
|
|
|
|
|
|
struct pizza {
|
|
|
|
float prize;
|
|
|
|
char name[LINESIZE];
|
|
|
|
};
|
2020-09-30 20:00:48 +00:00
|
|
|
struct pizza nulova;
|
|
|
|
struct pizza tuniakova = {
|
2020-09-30 18:31:17 +00:00
|
|
|
.name="Tuniakova",
|
|
|
|
.prize=2.3
|
|
|
|
};
|
2020-09-30 20:00:48 +00:00
|
|
|
|
|
|
|
int main(){
|
2020-09-29 17:23:12 +00:00
|
|
|
int POCET_JEDAL=0;
|
2020-09-30 18:31:17 +00:00
|
|
|
// Nastavíme všetky bajty pamäte na nulu
|
|
|
|
// Alebo staticky priradime nejake hodnoty
|
|
|
|
memset(&tuniakova, 0,sizeof(struct pizza));
|
|
|
|
// Pozor, táto inicializácia funguje iba na novších prekladačoch
|
2020-09-29 17:23:12 +00:00
|
|
|
struct pizza jedalny_listok[POCET_JEDAL];
|
|
|
|
// Na začiatku celé pole vynulujeme, všetky pizze sú nulové
|
|
|
|
memset(jedalny_listok, 0,sizeof(struct pizza)*POCET_JEDAL);
|
|
|
|
struct pizza *prva = jedalny_listok;
|
|
|
|
struct pizza *druha = jedalny_listok + 1;
|
|
|
|
struct pizza *tretia = &jedalny_listok[2];
|
|
|
|
|
|
|
|
char line[LINE_SIZE];
|
|
|
|
while (1){
|
2020-09-30 20:00:48 +00:00
|
|
|
// Inicializujem pamäť
|
|
|
|
memset(line,0,LINE_SIZE);
|
|
|
|
// Do poľa načítam max. LINE_SIZE znakov zo štandardnéhgo vstupu.
|
|
|
|
char* r = fgets(line,LINE_SIZE,stdin);
|
|
|
|
// Overím si či bolo načítanie úspešné.
|
2020-09-30 20:24:59 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
struct pizza item;
|
|
|
|
int counter = 1;
|
|
|
|
while(read_pizza(stdin,&item)){
|
|
|
|
counter += 1;
|
|
|
|
printf("%s",item->name);
|
|
|
|
printf("%.2f",item->prize);
|
2020-09-30 20:00:48 +00:00
|
|
|
}
|
2020-09-30 20:24:59 +00:00
|
|
|
}
|
2020-09-30 20:00:48 +00:00
|
|
|
int search_string(const char* heap, const char* needle){
|
2020-09-30 20:24:59 +00:00
|
|
|
char pole[5]="abcd";
|
2020-09-30 20:00:48 +00:00
|
|
|
for (int i = 0; i < 5; i++){
|
|
|
|
printf("%c",pole[i+1]);
|
2020-09-29 17:23:12 +00:00
|
|
|
}
|
|
|
|
}
|
2020-09-30 20:00:48 +00:00
|
|
|
|
|
|
|
int read_pizza(struct pizza* item){
|
2020-09-30 20:24:59 +00:00
|
|
|
float value = strtof(line,struct pizza);
|
2020-09-30 20:00:48 +00:00
|
|
|
// Ak je návratová hodnota nula, premena reťazca sa nepodarila.
|
|
|
|
if (value == 0.0F){
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
item->prize = value;
|
|
|
|
strcpy(item->name, line);
|
|
|
|
return 1;
|
2020-09-30 18:31:17 +00:00
|
|
|
}
|
2020-09-30 20:00:48 +00:00
|
|
|
|
2020-09-30 18:31:17 +00:00
|
|
|
char hacker_script(char c){
|
|
|
|
char numbers[] = "0123456789";
|
|
|
|
char letters[] = "oizeasbtbq";
|
|
|
|
for (int i = 0; i < 10; i++){
|
2020-09-30 20:24:59 +00:00
|
|
|
if (tolower(c) == numbers[i]){
|
2020-09-30 18:31:17 +00:00
|
|
|
return letters[i];
|
|
|
|
}
|
2020-09-29 17:23:12 +00:00
|
|
|
}
|
|
|
|
}
|
2020-09-30 20:24:59 +00:00
|
|
|
|
2020-09-30 18:31:17 +00:00
|
|
|
////////////////////////
|
2020-09-30 20:24:59 +00:00
|
|
|
// ////////
|
|
|
|
// /////// //////
|
2020-09-30 18:31:17 +00:00
|
|
|
// //////// //////
|
|
|
|
// //////// //////
|
2020-09-30 20:24:59 +00:00
|
|
|
// ////// //////
|
|
|
|
// //// /////////
|
|
|
|
// ////////////
|
2020-09-30 18:31:17 +00:00
|
|
|
// /// ///////////
|
|
|
|
// //// //////////
|
|
|
|
// ///// /////////
|
|
|
|
// ////// ////////
|
|
|
|
// /////// ///////
|
|
|
|
////////////////////////
|