Oh didn't know that.
Code:
#include<stdio.h>
#include<conio.h>
#define MAX 40
int main()
{
int price[MAX],ticket[MAX],i,n,pos,xu,yu,s[MAX],j,z[MAX],q[MAX],min,t,pozk;
for(i=0;i<n;i++) cena[i]=karta[i]=0;
do
{
printf("Number of the city and fridges:");
scanf("%d",&n);
if(n>0 && n<MAX) break;
clrscr();
} while(1);
printf("Enter the price of the fridges");
xu=wherex();
yu=wherey();
xu=1;
yu++;
for(i=0;i<n;i++)
{
gotoxy(xu,yu);
scanf("%d",&price[i]);
xu+=5;
if(xu>80) xu=1,yu++;
}
printf("Entere the price of the tickets");
xu=wherex();
yu=wherey();
xu=1;
yu++;
for(i=0;i<n;i++)
{
gotoxy(xu,yu);
scanf("%d",&ticket[i]);
xu+=5;
if(xu>80) xu=1,yu++;
}
printf("\n\nEnter the city where you are located:");
do{
xu=wherex();
yu=wherey();
scanf("%d",&poz);
if(poz>0 && poz<n) break;
gotoxy(xu,yu);
printf(" ");
gotoxy(xu,yu);
}while(1);
s[0]=min;
for(i=0;i<n;i++)
{
s[i]=ticket[i]+price[i];
if(s[i]<min) min=s[i],pozk=j;
}
printf("Ticket:%d\n Price of the fridge:%d ",ticket[pozk],price[pozk]);
getch();
}
The problem with my code is that it's showing only the place where the cheapest ticket and price of the fridge are.