2021-10-12 17:20:19 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#define LINESIZE 100
|
|
|
|
|
|
|
|
struct Pizza {
|
|
|
|
char name[LINESIZE];
|
|
|
|
float prize;
|
|
|
|
};
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
char line[LINESIZE];
|
|
|
|
memset(line, 0, LINESIZE);
|
|
|
|
char name[LINESIZE];
|
|
|
|
struct Pizza jedalny_listok[LINESIZE];
|
|
|
|
memset(jedalny_listok, 0, sizeof(struct Pizza) * LINESIZE);
|
|
|
|
size_t velkost;
|
2021-10-12 18:34:11 +00:00
|
|
|
int a = 0;
|
|
|
|
int i = 0;
|
2021-10-13 11:22:54 +00:00
|
|
|
int c;
|
|
|
|
int d;
|
|
|
|
float pred;
|
2021-10-12 18:34:11 +00:00
|
|
|
float cena;
|
2021-10-13 11:22:54 +00:00
|
|
|
char strpred[LINESIZE];
|
|
|
|
memset(strpred,0,LINESIZE);
|
2021-10-12 17:20:19 +00:00
|
|
|
while (fgets(line, LINESIZE, stdin)) {
|
|
|
|
velkost = strlen(line);
|
|
|
|
if (velkost == 1 && line[velkost - 1] == '\n') {
|
|
|
|
break;
|
|
|
|
}
|
2021-10-12 18:34:11 +00:00
|
|
|
if (i == 0) {
|
|
|
|
strcpy(jedalny_listok[a].name, line);
|
2021-10-12 17:20:19 +00:00
|
|
|
|
2021-10-12 18:34:11 +00:00
|
|
|
i++;
|
|
|
|
a++;
|
|
|
|
}
|
|
|
|
else if (i == 1){
|
|
|
|
cena = atof(line);
|
|
|
|
jedalny_listok[a].prize = cena;
|
2021-10-12 17:20:19 +00:00
|
|
|
|
2021-10-12 18:34:11 +00:00
|
|
|
i--;
|
|
|
|
a++;
|
|
|
|
}
|
|
|
|
}
|
2021-10-13 11:22:54 +00:00
|
|
|
|
|
|
|
a = a / 2;
|
2021-10-14 08:09:30 +00:00
|
|
|
//printf("%d", a);
|
2021-10-14 08:17:15 +00:00
|
|
|
for (c = 0; c < a; c++){
|
|
|
|
for (d = 0; d < a; d++){
|
|
|
|
d++;
|
2021-10-13 11:22:54 +00:00
|
|
|
if (jedalny_listok[d].prize > jedalny_listok[d+2].prize){
|
|
|
|
pred = jedalny_listok[d].prize;
|
|
|
|
jedalny_listok[d].prize = jedalny_listok[d + 2].prize;
|
|
|
|
jedalny_listok[d+2].prize = pred;
|
2021-10-13 11:36:51 +00:00
|
|
|
strcpy(strpred, jedalny_listok[d - 1].name);
|
|
|
|
strcpy(jedalny_listok[d - 1].name, jedalny_listok[d + 1].name);
|
|
|
|
strcpy(jedalny_listok[d + 1].name, strpred);
|
2021-10-14 08:08:53 +00:00
|
|
|
|
2021-10-13 11:42:33 +00:00
|
|
|
}
|
|
|
|
else if(jedalny_listok[d].prize == jedalny_listok[d+2].prize){
|
|
|
|
if(strcmp(jedalny_listok[c].name, jedalny_listok[d].name) > 0){
|
|
|
|
strcpy(strpred, jedalny_listok[d - 1].name);
|
|
|
|
strcpy(jedalny_listok[d - 1].name, jedalny_listok[d + 1].name);
|
|
|
|
strcpy(jedalny_listok[d + 1].name, strpred);
|
|
|
|
}
|
2021-10-13 11:22:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
a = a * 2;
|
2021-10-12 18:34:11 +00:00
|
|
|
for (i = 0; i<a; i++){
|
2021-10-13 11:22:54 +00:00
|
|
|
|
2021-10-12 18:34:11 +00:00
|
|
|
if (i == 0 || i % 2 == 0) {
|
2021-10-14 08:08:53 +00:00
|
|
|
printf("%s", jedalny_listok[i].name);
|
2021-10-12 18:34:11 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("%f\n", jedalny_listok[i].prize);
|
|
|
|
}
|
2021-10-12 17:20:19 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|