cv2
This commit is contained in:
parent
5d47005014
commit
591ef45d85
@ -20,37 +20,36 @@ int compare_pizza(const void *a, const void *b) {
|
|||||||
int main(){
|
int main(){
|
||||||
struct pizza menu[LINESIZE];
|
struct pizza menu[LINESIZE];
|
||||||
int count = 0;
|
int count = 0;
|
||||||
char vstup1[LINESIZE];
|
char vstup[LINESIZE];
|
||||||
char vstup2[LINESIZE];
|
|
||||||
while (count < LINESIZE) {
|
while (count < LINESIZE) {
|
||||||
if (fgets(vstup1, LINESIZE, stdin)) {
|
if (fgets(vstup, LINESIZE, stdin)) {
|
||||||
vstup1[strcspn(vstup1, "\n")] = '\0';
|
vstup[strcspn(vstup, "\n")] = '\0';
|
||||||
if (strlen(vstup1) == 0) {
|
if (strlen(vstup) == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
strcpy(menu[count].name, vstup);
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fgets(vstup2, LINESIZE, stdin)) {
|
if (fgets(vstup, LINESIZE, stdin)) {
|
||||||
vstup2[strcspn(vstup2, "\n")] = '\0';
|
vstup[strcspn(vstup, "\n")] = '\0';
|
||||||
if (strlen(vstup2) == 0) {
|
if (strlen(vstup) == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
float cislo = strtof(vstup, NULL);
|
||||||
|
menu[count].price = cislo;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
float cislo = strtof(vstup2, NULL);
|
|
||||||
if(cislo != 0){
|
|
||||||
menu[count].price = cislo;
|
|
||||||
strcpy(menu[count].name, vstup1);
|
|
||||||
}
|
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
qsort (menu, count, sizeof(struct pizza), compare_pizza);
|
qsort (menu, count, sizeof(struct pizza), compare_pizza);
|
||||||
for(int i = 0; i < count;i++){
|
for(int i = 0; i < count;i++){
|
||||||
printf("%s\n", menu[i].name);
|
if(menu[i].price != 0){
|
||||||
printf("%f\n", menu[i].price);
|
printf("%s\n", menu[i].name);
|
||||||
|
printf("%f\n", menu[i].price);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user