เวลาเลือกที่นั่ง
https://www.mx7.com/view2/zxFPUmhJzfMKRMLS
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <stdlib.h>
static const char FILE_NAME[] = "namem.csv";
typedef struct namemovie{
char name_movie[30];
char time[30];
}namemovies;
namemovies getData(char data[]);
void showmovie(namemovies pdata);
void writeDataEdit (namemovies wdata[]);
namemovies AddData(char data[]);
namemovies EditData(char data[]);
void writeDataAdd(namemovies wdata, FILE *pw);
int main()
{
FILE * fp;
int i=0,ans=0,rec=0,erec;
char buffer[250],edit[50];
namemovies data[30];
char s,ro;
char a,b,c,d,e;
char a1,a2,a3,a4,a5;
char A,B,C,D,E;
float price=0;
float sum=0;
int re,ch;
char m;
int theater;
//int num_seat;
//char title [30];
//char tier [2];
//float showtime;
printf("---------------MOVIE------------------\n\n");
printf("MENU\n");
printf("1. Select Movie\n");
printf("2. Edit Movie\n");
printf("\n\nSelect Menu : ");
scanf("%s",&s);
printf("\n\n");
printf("------------------\n\n");
switch(s)
{
case '1' :
if(fp=fopen("namem.csv","r"));
do
{
m=getc(fp);
putchar(m);
} while(m !=EOF);
fclose(fp);
printf("\n\nEnter Movie [1,2,3] :");
scanf("%d",&m);
printf("\n#############################################################\n\n");
do
{
for(a=1;a<11;a++)
{
printf(" [A%d] ",a);
}
printf("\n");
for(b=1;b<11;b++)
{
printf(" [B%d] ",b);
}
printf("\n");
for(c=1;c<11;c++)
{
printf(" [C%d] ",c);
}
printf("\n");
for(d=1;d<11;d++)
{
printf(" [D%d] ",d);
}
printf("\n");
for(e=1;e<11;e++)
{
printf(" [E%d] ",e);
}
printf("\n\n");
printf("#############################################################\n\n");
printf("Select Seats\n");
printf("select Row : ");
scanf("%s",&ro);
printf("select numbered : ");
scanf("%d",&re);
printf("#############################################################\n\n");
if(ro=='a')
{
for(a=1;a<11;a++)
{
if(a==re)
{
printf(" [--] ");
}
else printf(" [A%d] ",a);
}
printf("\n");
for(b=1;b<11;b++)
{
printf(" [B%d] ",b);
}
printf("\n");
for(c=1;c<11;c++)
{
printf(" [C%d] ",c);
}
printf("\n");
for(d=1;d<11;d++)
{
printf(" [D%d] ",d);
}
printf("\n");
for(e=1;e<11;e++)
{
printf(" [E%d] ",e);
}
printf("\n\n");
printf("#############################################################\n\n");
}
if(ro=='b')
{
for(a=1;a<11;a++)
{
printf(" [A%d] ",a);
}
printf("\n");
for(b=1;b<11;b++)
{
if(b==re)
{
printf(" [--] ");
}
else printf(" [B%d] ",b);
}
printf("\n");
for(c=1;c<11;c++)
{
printf(" [C%d] ",c);
}
printf("\n");
for(d=1;d<11;d++)
{
printf(" [D%d] ",d);
}
printf("\n");
for(e=1;e<11;e++)
{
printf(" [E%d] ",e);
}
printf("\n\n");
printf("#############################################################\n\n");
}
if(ro=='c')
{
for(a=1;a<11;a++)
{
printf(" [A%d] ",a);
}
printf("\n");
for(b=1;b<11;b++)
{
printf(" [B%d] ",b);
}
printf("\n");
for(c=1;c<11;c++)
{
if(c==re)
{
printf(" [--] ");
}
else printf(" [C%d] ",c);
}
printf("\n");
for(d=1;d<11;d++)
{
printf(" [D%d] ",d);
}
printf("\n");
for(e=1;e<11;e++)
{
printf(" [E%d] ",e);
}
printf("\n\n");
printf("#############################################################\n\n");
}
if(ro=='d')
{
for(a=1;a<11;a++)
{
printf(" [A%d] ",a);
}
printf("\n");
for(b=1;b<11;b++)
{
printf(" [B%d] ",b);
}
printf("\n");
for(c=1;c<11;c++)
{
printf(" [C%d] ",c);
}
printf("\n");
for(d=1;d<11;d++)
{
if(d==re)
{
printf(" [--] ");
}
else printf(" [D%d] ",d);
}
printf("\n");
for(e=1;e<11;e++)
{
printf(" [E%d] ",e);
}
printf("\n\n");
printf("#############################################################\n\n");
}
if(ro=='e')
{
for(a=1;a<11;a++)
{
printf(" [A%d] ",a);
}
printf("\n");
for(b=1;b<11;b++)
{
printf(" [B%d] ",b);
}
printf("\n");
for(c=1;c<11;c++)
{
printf(" [C%d] ",c);
}
printf("\n");
for(d=1;d<11;d++)
{
printf(" [D%d] ",d);
}
printf("\n");
for(e=1;e<11;e++)
{
if(e==re)
{
printf(" [--] ");
}
else printf(" [E%d] ",e);
}
printf("\n");
printf("\n\n");
printf("#############################################################\n\n");
}
if (ro!='a')
{
if (ro!='b')
{
if (ro!='c')
{
if (ro!='d')
{
if (ro!='e')
{
printf("Sorry, You enter the wrong.\n");
}
}
}
}
}
if (ro=='a')
{
price=200;
}
else if (ro=='b')
{
price =160;
}
else if(ro=='c')
{
price = 160;
}
else if(ro=='d')
{
price = 160;
}
else if(ro=='e')
{
price = 160;
}
sum=price+sum;
printf("price %.2f\n",price);
printf("\ndo you want to select seat again ? yes[1] No[2] : ");
scanf("%d",&ch);
if(m==1)
{
printf("\ntheater : 1\n");
}
else if(m==2)
{
printf("\ntheater : 2\n");
}
else if(m==3)
{
printf("\ntheater : 3\n");
}
else if(m==4)
{
printf("\ntheater : 4\n");
}
else if(m==5)
{
printf("\ntheater : 5\n");
}
} while (ch==1);
printf("\nsum = %.2f",sum);
getch();
ภาษาC ต้องการให้จำที่นั่งเวลาเข้าลูปเลือกครั้งที่2
https://www.mx7.com/view2/zxFPUmhJzfMKRMLS
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <stdlib.h>
static const char FILE_NAME[] = "namem.csv";
typedef struct namemovie{
char name_movie[30];
char time[30];
}namemovies;
namemovies getData(char data[]);
void showmovie(namemovies pdata);
void writeDataEdit (namemovies wdata[]);
namemovies AddData(char data[]);
namemovies EditData(char data[]);
void writeDataAdd(namemovies wdata, FILE *pw);
int main()
{
FILE * fp;
int i=0,ans=0,rec=0,erec;
char buffer[250],edit[50];
namemovies data[30];
char s,ro;
char a,b,c,d,e;
char a1,a2,a3,a4,a5;
char A,B,C,D,E;
float price=0;
float sum=0;
int re,ch;
char m;
int theater;
//int num_seat;
//char title [30];
//char tier [2];
//float showtime;
printf("---------------MOVIE------------------\n\n");
printf("MENU\n");
printf("1. Select Movie\n");
printf("2. Edit Movie\n");
printf("\n\nSelect Menu : ");
scanf("%s",&s);
printf("\n\n");
printf("------------------\n\n");
switch(s)
{
case '1' :
if(fp=fopen("namem.csv","r"));
do
{
m=getc(fp);
putchar(m);
} while(m !=EOF);
fclose(fp);
printf("\n\nEnter Movie [1,2,3] :");
scanf("%d",&m);
printf("\n#############################################################\n\n");
do
{
for(a=1;a<11;a++)
{
printf(" [A%d] ",a);
}
printf("\n");
for(b=1;b<11;b++)
{
printf(" [B%d] ",b);
}
printf("\n");
for(c=1;c<11;c++)
{
printf(" [C%d] ",c);
}
printf("\n");
for(d=1;d<11;d++)
{
printf(" [D%d] ",d);
}
printf("\n");
for(e=1;e<11;e++)
{
printf(" [E%d] ",e);
}
printf("\n\n");
printf("#############################################################\n\n");
printf("Select Seats\n");
printf("select Row : ");
scanf("%s",&ro);
printf("select numbered : ");
scanf("%d",&re);
printf("#############################################################\n\n");
if(ro=='a')
{
for(a=1;a<11;a++)
{
if(a==re)
{
printf(" [--] ");
}
else printf(" [A%d] ",a);
}
printf("\n");
for(b=1;b<11;b++)
{
printf(" [B%d] ",b);
}
printf("\n");
for(c=1;c<11;c++)
{
printf(" [C%d] ",c);
}
printf("\n");
for(d=1;d<11;d++)
{
printf(" [D%d] ",d);
}
printf("\n");
for(e=1;e<11;e++)
{
printf(" [E%d] ",e);
}
printf("\n\n");
printf("#############################################################\n\n");
}
if(ro=='b')
{
for(a=1;a<11;a++)
{
printf(" [A%d] ",a);
}
printf("\n");
for(b=1;b<11;b++)
{
if(b==re)
{
printf(" [--] ");
}
else printf(" [B%d] ",b);
}
printf("\n");
for(c=1;c<11;c++)
{
printf(" [C%d] ",c);
}
printf("\n");
for(d=1;d<11;d++)
{
printf(" [D%d] ",d);
}
printf("\n");
for(e=1;e<11;e++)
{
printf(" [E%d] ",e);
}
printf("\n\n");
printf("#############################################################\n\n");
}
if(ro=='c')
{
for(a=1;a<11;a++)
{
printf(" [A%d] ",a);
}
printf("\n");
for(b=1;b<11;b++)
{
printf(" [B%d] ",b);
}
printf("\n");
for(c=1;c<11;c++)
{
if(c==re)
{
printf(" [--] ");
}
else printf(" [C%d] ",c);
}
printf("\n");
for(d=1;d<11;d++)
{
printf(" [D%d] ",d);
}
printf("\n");
for(e=1;e<11;e++)
{
printf(" [E%d] ",e);
}
printf("\n\n");
printf("#############################################################\n\n");
}
if(ro=='d')
{
for(a=1;a<11;a++)
{
printf(" [A%d] ",a);
}
printf("\n");
for(b=1;b<11;b++)
{
printf(" [B%d] ",b);
}
printf("\n");
for(c=1;c<11;c++)
{
printf(" [C%d] ",c);
}
printf("\n");
for(d=1;d<11;d++)
{
if(d==re)
{
printf(" [--] ");
}
else printf(" [D%d] ",d);
}
printf("\n");
for(e=1;e<11;e++)
{
printf(" [E%d] ",e);
}
printf("\n\n");
printf("#############################################################\n\n");
}
if(ro=='e')
{
for(a=1;a<11;a++)
{
printf(" [A%d] ",a);
}
printf("\n");
for(b=1;b<11;b++)
{
printf(" [B%d] ",b);
}
printf("\n");
for(c=1;c<11;c++)
{
printf(" [C%d] ",c);
}
printf("\n");
for(d=1;d<11;d++)
{
printf(" [D%d] ",d);
}
printf("\n");
for(e=1;e<11;e++)
{
if(e==re)
{
printf(" [--] ");
}
else printf(" [E%d] ",e);
}
printf("\n");
printf("\n\n");
printf("#############################################################\n\n");
}
if (ro!='a')
{
if (ro!='b')
{
if (ro!='c')
{
if (ro!='d')
{
if (ro!='e')
{
printf("Sorry, You enter the wrong.\n");
}
}
}
}
}
if (ro=='a')
{
price=200;
}
else if (ro=='b')
{
price =160;
}
else if(ro=='c')
{
price = 160;
}
else if(ro=='d')
{
price = 160;
}
else if(ro=='e')
{
price = 160;
}
sum=price+sum;
printf("price %.2f\n",price);
printf("\ndo you want to select seat again ? yes[1] No[2] : ");
scanf("%d",&ch);
if(m==1)
{
printf("\ntheater : 1\n");
}
else if(m==2)
{
printf("\ntheater : 2\n");
}
else if(m==3)
{
printf("\ntheater : 3\n");
}
else if(m==4)
{
printf("\ntheater : 4\n");
}
else if(m==5)
{
printf("\ntheater : 5\n");
}
} while (ch==1);
printf("\nsum = %.2f",sum);
getch();