Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include<string.h>
- typedef enum {
- ONE_BED, TWO_BEDS, SUPERIOR, DELUXE, SUITE
- } roomtype;
- typedef struct {
- int number;
- roomtype type;
- int occupied;
- double price;
- } room;
- typedef struct {
- char name[50];
- char address[50];
- int num_rooms;
- room rooms[100];
- } hotel;
- int main() {
- hotel hotels[3];
- int i;
- for(i = 0; i < 3; i++) {
- printf("Vnesete ime i adresa na hotelot %d:\n", i + 1);
- gets(hotels[i].name);
- gets(hotels[i].address);
- printf("Vnesete broj na sobi vo hotelot %d:\n", i + 1);
- scanf("%d", &hotels[i].num_rooms);
- int j;
- printf("Vnesete podatoci za sekoja od sobite na hotelot %d:\n", i + 1);
- for(j = 0; j < hotels[i].num_rooms; j++) {
- printf("Vnesete podatoci za soba %d:\n", j + 1);
- int type;
- scanf("%d %d %d %lf",
- &hotels[i].rooms[j].number,
- &type,
- &hotels[i].rooms[j].occupied,
- &hotels[i].rooms[j].price);
- getchar();
- hotels[i].rooms[j].type = (roomtype) type;
- }
- }
- char hotel_to_search[50];
- roomtype type_to_search;
- gets(hotel_to_search);
- int type;
- scanf("%d", &type);
- type_to_search = (roomtype) type;
- for(i = 0; i < 3; i++) {
- if(!strcmp(hotels[i].name, hotel_to_search)) {
- int j;
- for(j = 0; j < hotels[i].num_rooms; j++) {
- if(hotels[i].rooms[j].type == type_to_search && !hotels[i].rooms[j].occupied) {
- printf("Sobata so broj %d e slobodna\n", hotels[i].rooms[j].number);
- }
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement