#include <stdio.h>
//#include <conio.h>
#include <stdlib.h>
void input_data(void);
void output_data(void);
void change_data();
void print(int);
void search_data();
void finish_application(void);
int i;
struct touring
{char country[100];
 char city[100];
 int tour_duration;
 int cost;
 } tour[100];
int main()
//void main (void)
{
 int p;
 printf("Welcome to Data Base of travel company King of World \n");
  while(1)
{
printf("Enter 1 if you want to enter data \n");
 printf("Enter 2 if you want to look at data\n");
 printf("Enter 3 if you want to change at data\n");
 printf("Enter 4 if you want to search data\n");
 printf("Enter 5 if you want to finish work with application\n");
 printf("Select:");
  scanf("%d",&p);
    switch(p)
    {
    case 1 :
        input_data();
        break;
    case 2:
        output_data();
        break;        
     case 3:
           change_data();
        break;  
     case 4:
           search_data();
        break;             
    case 5:
        finish_application();
        break;       
    default: printf("\n\t Any of points isn't chosen\n");
    }
 
}
return 0;
}
void input_data(void)
{
 for(i=0;i<3;i++)
 {printf("Enter data  about %d' tour\n",i);
 printf("Enter country:");
 scanf("%s",tour[i].country);
 printf("Enter city:");
 scanf("%s",tour[i].city);
 printf("Enter number of days of tour:");
 scanf("%d",&tour[i].tour_duration);
 printf("Enter cost:");
 scanf("%d",&tour[i].cost);
 printf("\n");
 printf("\n");
 }
}
void change_data()
{
    int a;
    printf("Enter number of record\n");
    scanf("%d",&i);
    printf("Select item for change\n");
    printf("1.country\n");
    printf("2.city\n");
    printf("3.numbers of days\n");
    printf("4.cost\n");
    scanf("%d", &a);
    switch (a)
    {
        case 1: {
                printf("Enter new country\n");
                scanf("%s", tour[i].country);
                break;
                }
        case 2: {
                printf("Enter new city\n");
                scanf("%s", tour[i].city);
                break;
                }
        case 3: {
                printf("Enter new numbers of days\n");
                scanf("%d", &tour[i].tour_duration);
                
                break;
                }
       case 4: {
                printf("Enter new cost\n");
                scanf("%d", &tour[i].cost);
                
                break;
                }         
    }
}
void output_data(void)
{for(i=0;i<3;i++)
 {printf("Data about %d' tour\n",i);
 printf("Country:%s\n",tour[i].country);
 printf("City:%s\n",tour[i].city);
 printf("Number of days of tour:%d\n",tour[i].tour_duration);
 printf("Cost:%d\n",tour[i].cost);
 printf("\n");
 printf("\n");
 }
 }
void print(int i)
{
 printf("Data about %d' tour\n",i);
 printf("Country:%s\n",tour[i].country);
 printf("City:%s\n",tour[i].city);
 printf("Number of days of tour:%d\n",tour[i].tour_duration);
 printf("Cost:%d\n",tour[i].cost);
}
void search_data()
{ 
    int n=0;
    int i=0;
    int d=1;
    char b[100];
    printf("Enter 1 for search by country\n");
    printf("Enter 2 for search by city\n");
    printf("Enter 3 for search by number of days of tour\n");
    printf("Enter 4 for search by cost of tour\n");   
    scanf("%d",&n);
    switch(n)
    {
    case 1:
        {
            printf("Enter country \n");
            scanf("%s",b);
            for(i=0;i<3;i++)
                if((tour[i].country==b))
                    print(i);
            break;
        }
    case 2 :
        {
            printf("Enter city \n");
            scanf("%s",b);
            for(i=0;i<3;i++)
                if((tour[i].city==b))
                    print(i);
            break;
        }
    case 3 :
        {
            printf("Enter number of days of tour \n");
            scanf("%d",&d);
            for(i=0;i<3;i++)
                if(tour[i].tour_duration==d)
                    print(i);
            break;
        }
    case 4 :
        {
            printf("Enter cost of tour \n");
            scanf("%d",&d);
            for(i=0;i<3;i++)
                if(tour[i].cost==d)
                    print(i);
            break;
        }
}
}
    
                        
 void finish_application()
{
 exit(1);
} 
