如图是什么脚本语言和编程语言的区别,谢谢!!


//pastriver.c/***********************************This code is used to answer the pastriver question.Note: 12/2/2006
coded by YunDanFengQing www.cfannet.com***********************************/#include <stdio.h>#define MAX 100typedef enum BOOL{ FALSE = 0, TRUE = 1 }BOOL;typedef union Items{struct
{char boy
: 1;char girl : 1;char father : 1;char mother : 1;char police : 1;char thief : 1;char : 0;};char c;}*pItems, Items;struct{Items item[MAX];int boat[MAX];int length;}stack; int Boat[2];Items ItemMask[12];char* msg[4] = { "comes back single.", "comes back together.", "pasts the river single.", "past the river together." };char* msgn[12] = { "father", "mother", "police", "thief", "police and the thief", "police and the father","police and the mother", "police and the boy", "police and the girl", "father and the boy", "mother and the girl", "father and the mother"};BOOL IsLegal ( Items item ){Items t1, t2, t3;Items t4, t5, t6;t1.c = 0, t2.c = 0, t3.c = 0;t4.c = 0, t5.c = 0, t6.c = 0;t1.girl = 1, t1.father = 1, t1.mother = 0;t4.girl = 1, t4.father = 1, t4.mother = 1;t2.boy
= 1, t2.father = 0, t2.mother = 1;t5.boy
= 1, t5.father = 1, t5.mother = 1;t3.thief = 1, t3.police = 0;t6.thief = 1, t6.police = 1;if (( t4.c & item.c ) == t1.c ) {return FALSE; }if (( t5.c & item.c ) == t2.c ) {return FALSE;}if ((( item.c & t6.c ) == t3.c ) && (( item.c ^ t3.c ) != 0)) {return FALSE;}
return TRUE;}BOOL IsInStack ( Items item, int boat ){int i = 0;for ( i = 0; i < stack.length; ++i ) {if (( item.c == stack.item[i].c ) && ( boat == stack.boat[i] )) {return TRUE;}}return FALSE;}BOOL IsStackFull (){return stack.length >= MAX ? TRUE : FALSE;}BOOL Rule ( pItems itemL, pItems itemR, int boat, int i ){Items left, right;if ( 0 == boat ) {left.c = itemL->c;right.c = itemR->c;}else {left.c = itemR->c;right.c = itemL->c;}if (( left.c & ItemMask[i].c ) != ItemMask[i].c ) {return FALSE;}left.c ^= ItemMask[i].c;right.c ^= ItemMask[i].c;if ( 0 == boat ) {itemL->c = left.c;itemR->c = right.c;}else {itemL->c = right.c;itemR->c = left.c;}return TRUE;} BOOL PastRiver ( Items itemL, Items itemR, int boat ){Items newL, newR;int i = 0, j = 0;if ( itemL.c == 0 ) {return TRUE;}for ( i = 0; i < 12; ++i ){newL.c = itemL.c, newR.c = itemR.c;if ( TRUE == Rule ( &newL, &newR, boat, i )) {if (( TRUE == IsLegal (newL)) && ( TRUE == IsLegal (newR) )) {if (( FALSE == IsInStack ( newL, boat )) && ( FALSE == IsStackFull() )) {stack.item[stack.length].c = newL.c;stack.boat[stack.length] = boat;stack.length ++;if ( TRUE == PastRiver ( newL, newR, Boat[boat] )) {if (( 0 == boat ) && ( i < 4 )) {j = 2;}if (( 0 == boat ) && ( i >= 4 )) {j = 3;}if (( 1 == boat ) && ( i < 4 )) {j = 0;}if (( 1 == boat ) && ( i >= 4 )) {j = 1;}
printf ( "The %s %s\n", msgn[i], msg[j] );return TRUE;}}}}
}return FALSE;}void Init(){int i = 0;stack.length = 0;Boat[0] = 1;Boat[1] = 0;for ( i = 0; i < 12; ++i ) {ItemMask[i].c = 0;}ItemMask[0].father = 1;ItemMask[1].mother = 1;ItemMask[2].police = 1;ItemMask[3].thief
= 1;ItemMask[4].police = 1, ItemMask[4].thief
= 1;ItemMask[5].police = 1, ItemMask[5].father = 1;ItemMask[6].police = 1, ItemMask[6].mother = 1;ItemMask[7].police = 1, ItemMask[7].boy
= 1;ItemMask[8].police = 1, ItemMask[8].girl
= 1;ItemMask[9].father = 1, ItemMask[9].boy
= 1;ItemMask[10].mother = 1, ItemMask[10].girl
= 1;ItemMask[11].father = 1, ItemMask[11].mother = 1;
}int main (){Items itemL, itemR;itemL.c = 0, itemR.c = 0;itemL.father = 1, itemL.mother = 1;itemL.boy = 1, itemL.girl = 1;itemL.police = 1, itemL.thief = 1;Init();stack.item[stack.length].c = itemL.c;stack.boat[stack.length] = 1;stack.length++;if ( FALSE == PastRiver ( itemL, itemR, 0 )) {printf ("BAD!!\n");}getchar();
return 0;}

下图是书《单片机与c语言》中的,图中的=~是什么意思,最好帮我解释一下程序,谢谢急,十分感谢...
下图是书《单片机与c语言》中的,图中的=~是什么意思,最好帮我解释一下程序,谢谢急,十分感谢
展开
选择擅长的领域继续答题?
{@each tagList as item}
${item.tagName}
{@/each}
手机回答更方便,互动更有趣,下载APP
提交成功是否继续回答问题?
手机回答更方便,互动更有趣,下载APP
展开全部~是取反的意思,那条语句的意思就是:把变量L2按位取反,原来的位为0,再变为1赋值给L2。反之相反咯。在这个程序里面的意思,就是P1^7口交替赋值为0或者1;估计控制LED灯闪烁类的吧
本回答由提问者推荐已赞过已踩过你对这个回答的评价是?评论
收起arm芯片是一种处理器核心(CPU core)的名称。它是一种由英国ARM公司设计和制造的微处理器架构,广泛用于各种电子设备,包括计算机、智能手机、平板电脑、嵌入式系统等。 ARM架构具有高度可定制性和灵活性,使得开发者可以根据应用需求来选...
点击进入详情页本回答由深圳市颖特新科技提供
收起
更多回答(1)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
为你推荐:
下载百度知道APP,抢鲜体验使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。扫描二维码下载
×个人、企业类侵权投诉
违法有害信息,请在下方选择后提交
类别色情低俗
涉嫌违法犯罪
时政信息不实
垃圾广告
低质灌水
我们会通过消息、邮箱等方式尽快将举报结果通知您。说明
做任务开宝箱累计完成0
个任务
10任务
50任务
100任务
200任务
任务列表加载中...

选择擅长的领域继续答题?
{@each tagList as item}
${item.tagName}
{@/each}
手机回答更方便,互动更有趣,下载APP
提交成功是否继续回答问题?
手机回答更方便,互动更有趣,下载APP
PLC培训可以去程控自动化PLC培训请认准程控自动化!专业化,标准化,系统化培训,帮助您60天变成PLC专家! 程控自动化,是一家承接电气自动化程序设计,电气与非标机械设计,设备改造,PLC培训的自动化公司。PLC培训实行一对一的随到随学培...
点击进入详情页本回答由闵行程控工程师培训提供#include<stdio.h>int ASCII_2_INT(char *s,int len){int num=0;while(len--){if(*s>'9'
*s<'0')//如果输入的ID有出现非数字字符的时候,则不再转换。break;num*=10;num+=*s-'0';s++;}return num;}int main(){char ID[20];int y,m,d;printf("Input your ID:\n");gets(ID);y=ASCII_2_INT(&ID[6],4);m=ASCII_2_INT(&ID[10],2);d=ASCII_2_INT(&ID[12],2);printf("%-6d%4c%02d%4c%02d%6d\n",y,' ',m,' ',d,y+m+d);}5457842696448

我要回帖

更多关于 编写一个c程序,运行时输出以下图形 的文章

 

随机推荐