当前位置:首页 » 编程软件 » 编程安排座位

编程安排座位

发布时间: 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,员工的进出顺序

靠门的后进先出。
会议室座位通常遵循以右为尊、中间为尊、前排为上、面门为上的规则。

热点内容
安通加密 发布:2024-11-08 00:25:51 浏览:138
为什么安卓和苹果单核差距那么大 发布:2024-11-08 00:25:50 浏览:438
存储器的种类 发布:2024-11-08 00:14:10 浏览:188
戴尔服务器bios怎么看日志 发布:2024-11-08 00:09:56 浏览:961
有渔编程下载 发布:2024-11-07 23:56:49 浏览:714
汉字在计算机内部存储 发布:2024-11-07 23:55:20 浏览:714
java启动jar 发布:2024-11-07 23:49:19 浏览:607
java方法的参数传递参数 发布:2024-11-07 23:37:12 浏览:445
安卓手机为什么一直停在开机画面 发布:2024-11-07 23:36:16 浏览:650
java是一种面向对象的语言 发布:2024-11-07 23:21:53 浏览:981