Sie sind auf Seite 1von 2

Programrea calculatoarellor

Nr 7
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<stdlib.h>
typedef struct hotel
{ char name[40];
char city[10];
char grade;
int rc;
int nr;
}hotel;
void reads(hotel *H,int n);
void shows(hotel *H,int n);
int searchs(hotel *H,int n);
void sorts(hotel *H,int n);
void modifys(hotel *H,int k);
hotel* appends(hotel *H,int *n,hotel a);
hotel* prepends(hotel *H,int *n,hotel a);
hotel* inserts(hotel *H,int *n,hotel a,int k);
hotel* deletes(hotel *H,int *n,int k);
void swaps(hotel *H,int k1,int k2);
int saves(hotel *H,int n,char *fmain);
int loads(hotel *H,int n,char *fmain);
void reads(hotel *H,int n)
{puts("Dati info despre hoteluri:");
for(i=0;i<n;i++)
{printf("Hotel %d:",i+1);
printf("Denumire:");
scanf("%s",&H[i].name);
fflush(stdin);
gets(H[i].name);
printf("Oras?:");
scanf("%s",&H[i].city);
printf("Gradul?:");
scanf("%d",&H[i].grade);
printf("Pretul?:");
scanf("%d",&H[i].rc);
printf("Nr_camere?:");
scanf("%d",&H[i].nr);}
}
void shows(hotel *H,int n)
{int i;
puts("Info despre hoteluri:");
for(i=0;i<n;i++)
{
printf("%d.Denumire:%s,Oras:%s,Gradul:%d,Pretul:%d,Nr_camere:
%d",i+1,H[i].name,H[i].city
H[i].grade,H[i].rc,H[i].nr);}return;}

int searchs(hotel *H,int n,char *num)


{int i;
for(i=0;i<n;i++)
{if(stricmp(H[i].name,num)==0){return i;}
} return -1;}
void sorts(hotel *H,int n)
{int i,k;hotel t;
for(i=0;i<n-1;i++)
{for(k=0;k<n-1-i;k++)
{if(strcmp(H[i].name,H[k+1].name)>0)
{t=H[k];H[k]=H[k+1];H[k+1]=t;}}}
return;}
void modifys(hotel *H,int k)
{int f;
printf("De modificat denumirea hotelului?(1/0):");
scanf("%d",&f);
if(f){printf("Denumirea?:");
fflush(stdin);
gets(H[i].name);}
printf("de modificat orasul?(1/0):");
scanf("%d",&f);
if(f){printf("Orasul?:");
scanf("%d",&H[i].city);}
printf("de modificat gradul")