當前位置:首頁 » 編程軟體 » 編程安排座位

編程安排座位

發布時間: 2024-06-19 22:45:29

① C紼嬪簭緙栫▼涔嬫満紲ㄥ駭浣嶉勫畾緋葷粺 奼傝В

#include<conio.h>
#include<stdio.h>

void main()
{
int i=0,j=0,count=0,hang=0;
char lie;
char a[7][4]={ {'A','B','C','D'},
{'A','B','C','D'},
{'A','B','C','D'},
{'A','B','C','D'},
{'A','B','C','D'},
{'A','B','C','D'},
{'A','B','C','D'} };

while(count<=28)
{
printf("\n\n璇瘋㈢エ錛孹涓哄凡緇忚㈠嚭鐨勫駭浣嶏紝璇烽夋嫨鍏朵粬搴т綅銆\n");

for(i=0;i<7;i++)
{
for(j=0;j<4;j++)
{
printf("%c ",a[i][j]);
}
printf("\n");
}

printf("\n璇瘋緭鍏ヤ綘鎵瀹氬駭浣嶇殑琛屽彿(1~7琛)錛\n");
fflush(stdin);
scanf("%d",&hang);
if((hang<1)||(hang>7))
{
printf("鏃犳晥杈撳叆!\n");
continue;
}

printf("璇瘋緭鍏ヤ綘鎵瀹氬駭浣嶇殑鍒楀彿(A,B,C,D)錛\n");
fflush(stdin);
scanf("%c",&lie);
if((lie<'A')||(lie>'D'))
{
printf("鏃犳晥杈撳叆!\n");
continue;
}

if(a[hang-1][lie-'A']=='X')
{
printf("瀵逛笉璧鳳紝璇ュ駭浣嶅凡緇忚璁浜嗐\n");
continue;
}
else
{
printf("鎮ㄧ殑搴т綅鏄錛%d琛%c搴э紝紲濇偍鏃呴旀剦蹇錛併\n",hang,lie);
a[hang-1][lie-'A']='X';
}
}

printf("鏈鑸鐝鐨勬墍鏈夊駭浣嶅凡緇忚㈠嚭銆\n");
getch();
}

② 鍙浠ョ敤 Python 緙栫▼璇璦鍋氬摢浜涚炲囧ソ鐜╃殑浜嬫儏

澶т竴鍒氬Python鐨勬椂鍊欙紝鍐欎簡涓鍙12306鐖鉶錛岄噰闆嗚濺嬈°佹椂鍒昏〃鏁版嵁
澶氱嚎紼嬮噰闆嗭紝緇忚繃涓嶆柇璋冭瘯緇堜簬紼沖畾錛岄熷害涔熻繕鍙浠
姣忓ぉ澶ф傚彲浠ラ噰闆嗗埌2000澶氫釜杞︾珯錛5000澶氫釜杞︽★紝5涓囧氭潯鏃跺埢淇℃伅錛堣繖浜涗俊鎮姣忓ぉ閮藉湪鍙樼殑錛屾墍浠ヨ佽劇疆涓嶅悓鏃ユ湡錛岀劧鍚庝繚瀛橈級

褰撶劧榪欎笉綆楁湁鎰忔濈殑

鏈夋剰鎬濈殑鏄榪欎釜
鍙浠ュ彲瑙嗗寲鏄劇ず鍚勪釜絝欑偣涓嶅悓鏃墮棿鐨勮濺杈嗚繍琛屾儏鍐碉紙褰撶劧鏄劇ず閮ㄥ垎涓嶆槸鐢≒ython鍐欑殑浜嗭級鍙浠ュ彲瑙嗗寲鏄劇ず鍚勪釜絝欑偣涓嶅悓鏃墮棿鐨勮濺杈嗚繍琛屾儏鍐碉紙褰撶劧鏄劇ず閮ㄥ垎涓嶆槸鐢≒ython鍐欑殑浜嗭級

閲囬泦浜嗚繖涔堝氭暟鎹涓嶅埄鐢ㄥ氨澶鍙鎯滀簡錛屼簬鏄鍔ㄤ簡鐐硅剳絳嬶紝鎶婃暟鎹鍒╃敤璧鋒潵錛屽氨鏈変簡涓嬮潰榪欎簺錛堜笅闈㈠氨涓嶱ython鏃犲叧浜嗭級

閭d釜鏃跺欓搧閬撻儴榪樻病鏈夊彂甯冨畼緗戠殑璐紲ˋPP錛屼簬鏄鏈変簡榪欎釜

鑷宸卞仛浜嗕釜璁㈢エ鐨凙PP錛屽彲鏌ヨ㈣濺嬈°佹椂鍒匯佷綑紲ㄣ佹f櫄鐐
錛堣峰拷鐣ュ浘涓婄殑姘村嵃錛岃繖涓獮PP棣栧彂鏄鍦ㄧ櫨搴︾伀杞﹀惂錛屾噿寰楀啀閲嶆柊鎴鍥句簡錛

鍡錛岃櫧鐒跺綋鏃舵病鏈夊畼鏂圭殑APP錛屼絾絎涓夋柟鐨勮繕涓嶅皯錛屼笂闈㈢殑鍔熻兘涔熸病浠涔堟柊椴滅殑
涓嶈繃涓嬮潰鍑犱釜鍔熻兘涓鑸鐨凙PP鏄娌℃湁鐨

杞︾珯璇︾粏淇℃伅鏌ヨ錛屽寘鎷鎵鍦ㄥ湴鍧銆佹槸鍚﹀姙鐞嗘棶瀹涔橀檷銆佹槸鍚﹀姙鐞嗚屽寘涓氬姟錛屼篃鏈変竴浜涢潪璺鍐呬漢澹涓嶄細鍦ㄦ剰鐨勪俊鎮錛屾瘮濡傛墍灞炵嚎璺銆佹墍鍦ㄨ礬灞銆佹槸鍚︿負鎺ョ畻絝欑瓑絳

緙栫粍銆佷箻鍔°佸楄窇淇℃伅

涓婇潰涓や釜鍔熻兘闈炶礬鍐呬漢澹搴旇ヤ笉浼氱敤鐨勫お澶氾紝涓嬮潰榪樻湁鍑犱釜瀹炵敤鐨勫姛鑳

鐢佃瘽璁㈢エ
鍦ㄩ珮宄版椂鏈熻㈢エ鐢佃瘽緇忓父鎵撲笉閫氾紝鍏跺疄榪欎釜鏄鏈変簺灝忔妧宸х殑錛屽姞鎷ㄥ悓璺灞鍏跺畠鍩庡競鍖哄彿鏁堟灉浼氬ソ寰堝氾紙褰撴椂鐢佃瘽璁㈢エ鏄瑕佹嫧鎵撳嚭鍙戝湴鎵鍦ㄨ礬灞鐨勭數璇濈殑錛屼笉鐭ラ亾鐜板湪鏄鍚﹀疄鐜頒簡鐢佃瘽璺ㄨ礬灞鍞紲錛

搴т綅鍒嗗竷錛屾兂鍒烽潬紿楀駭浣嶅氨鐪嬭繖涓鍚

鏍規嵁浜岀淮鐮侀獙紲ㄧ湡浼

灝嗘潵鐨勪綘涓瀹氫細鎰熻阿浠婂ぉ鎷煎懡鍔鍔涚殑浣 (浜岀淮鐮佽嚜鍔ㄨ瘑鍒)

鏀劇エ鏃墮棿鏌ヨ

鐣岄潰涓戠殑瑕佹伙紝璇峰ぇ瀹跺拷鐣ョ晫闈㈠惂銆傘

③ C璇璦緙栫▼錛氬啓涓涓璁㈠駭紼嬪簭錛岄粯璁ゅ叡鏈12涓搴т綅

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#defineSEAT_NUM12

/*瀹氫箟鑿滃崟閫夐」*/
typedefenumFUNC_SELECT{
FUNC_A,
FUNC_B,
FUNC_C,
FUNC_D,
FUNC_INVALID
}FUNC_SELECT;

/*瀹氫箟搴т綅緇撴瀯浣*/
typedefstructSEAT_INFO{
intnum;
intassignment;
charcustomer[200];
}SEAT_INFO;

SEAT_INFOseatInfo[SEAT_NUM];


/*鏄劇ず鑿滃崟欏瑰苟鑾峰彇鐢ㄦ埛杈撳叆*/
FUNC_SELECTshowmenu()
{
charc;
FUNC_SELECTfunc;

do
{
printf("Tochooseafunction錛宔nteritsletterlabel錛歕n");
printf("a錛嶴howallseats ");
printf("b錛嶢 ");
printf("c錛嶥eleteaseatassignment ");
printf("d錛嶲uit ");

c=getchar();
getchar();//skiptheenterkey

printf(" ");

switch(c)
{
case'a':
case'A':
func=FUNC_A;
break;
case'b':
case'B':
func=FUNC_B;
break;
case'c':
case'C':
func=FUNC_C;
break;
case'd':
case'D':
func=FUNC_D;
break;
default:
printf("Invalidinput! ");
func=FUNC_INVALID;
break;
}
}while(func==FUNC_INVALID);

returnfunc;

}

voidfunc_a()
{
inti;

printf("Showallseats: ");

printf("%10s%20s%20s ","Num","Assignment","Customer");
for(i=0;i<SEAT_NUM;i++)
{
printf("%10d%20d%20s ",seatInfo[i].num,seatInfo[i].assignment,seatInfo[i].customer);
}
}

intget_seat(intassignment)
{
intnum;
chartmpstr[200];
intflag=0;
inti;

do
{
flag=0;
printf("PleaseinputSeatNum: ");
fgets(tmpstr,200,stdin);

if(strlen(tmpstr)>10)
{
flag=0;
printf("Invalidinput! ");
continue;
}
else
{
flag=1;
num=atoi(tmpstr);
}
for(i=0;i<SEAT_NUM;i++)
{
if(seatInfo[i].num==num)
{
flag=1;
if(seatInfo[i].assignment!=assignment)
flag=2;
break;
}
}
if(flag==0)
{
printf("Seatnuminvalid! ");
}
elseif(flag==2)
{
if(assignment==0)
printf("Seatalreadyassigned! ");
else
printf("Seatnotassigned! ");
}

}while(flag!=1);

returni;
}

voidget_customer(char*customer)
{
chartmpstr[200];
intflag=0;

do
{
printf("Pleaseinputcustomer: ");

fgets(tmpstr,200,stdin);

if(strlen(tmpstr)>100)
{
flag=0;
printf("customernametoolong! ");
}
else
{
flag=1;
strcpy(customer,tmpstr);
customer[strlen(tmpstr)-1]=0;
}
}while(flag==0);
}

voidfunc_b()
{
intnum;
charcustomer[200];

printf("A ");

num=get_seat(0);
get_customer(customer);

seatInfo[num].assignment=1;
strcpy(seatInfo[num].customer,customer);
}

voidfunc_c()
{
intnum;

printf("Deleteaseatassignment ");
num=get_seat(1);
seatInfo[num].assignment=0;
strcpy(seatInfo[num].customer,"");
}

main()
{
inti;
FUNC_SELECTm;

/*鍒濆嬪寲搴т綅緇撴瀯浣*/
memset(seatInfo,0,sizeof(seatInfo));
for(i=0;i<SEAT_NUM;i++)
{
seatInfo[i].num=i+1;
}


do
{
m=showmenu();

switch(m)
{
caseFUNC_A:
func_a();
break;
caseFUNC_B:
func_b();
break;
caseFUNC_C:
func_c();
break;
default:
break;
}

}while(m!=FUNC_D);

printf("Quit! ");
}

編程會議室座位總數Seatnum,員工的進出順序

靠門的後進先出。
會議室座位通常遵循以右為尊、中間為尊、前排為上、面門為上的規則。

熱點內容
linuxnginx與php 發布:2024-11-07 22:33:32 瀏覽:78
android語音sdk 發布:2024-11-07 22:26:58 瀏覽:614
uuidjava生成 發布:2024-11-07 22:22:31 瀏覽:7
裝修家中需要配置哪些東西 發布:2024-11-07 22:21:11 瀏覽:82
什麼安卓的平板電腦最好用 發布:2024-11-07 22:21:05 瀏覽:552
linux最大內存 發布:2024-11-07 22:11:28 瀏覽:627
誰編程的楚辭 發布:2024-11-07 22:06:22 瀏覽:334
安卓暴力摩托叫什麼 發布:2024-11-07 22:05:03 瀏覽:343
c語言維基 發布:2024-11-07 21:59:49 瀏覽:787
記錄數據到緩存區 發布:2024-11-07 21:58:19 瀏覽:330