sbit P10=P1^0;//表决人1
sbit P11=P1^1;//表决人2
sbit P12=P1^2;//表决人3
sbit P13=P1^3;//表决人4
sbit P14=P1^4;//表决人5
sbit P15=P1^5;//结果显示
int a=0;
int b=0;
int i=0;
void main()
{
while(1)
{
if(P10==0)
a++;
else
b++;
if(P11==0)
a++;
else
b++;
if(P12==0)
a++;
else
b++;
if(P13==0)
a++;
else
b++;
if(P14==0)
a++;
else
b++;
if(a>b)
P15=0;
else
P15=1;
a=b=0;
for(i=0;i<255;i++)
{}
}
}
51单片机表决器C语言编程~
要求:1、应用外部中断设置开始和停止按键,可以控制系统的工作状态。
2、在开始表决的过程里,能够准确记录下每个表决开关是否被按下过(记忆功能)。
3、设置两个指示灯分别代表“通过”和“否
4人表决器表决器好设计,用5个三输入的与非门就行了,五人表决器就要麻烦了,真值表好列,用逻辑代数或卡诺图求出简化的逻辑表达式并演化成与非的形式就不好化了,这个问题你还是想老师寻求一点帮助吧
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity bj is
port(a:in std_logic_vector(4 downto 0);
y:out std_logic);
end bj;
architecture aa of bj is
signal x:std_logic; begin
x<=a(0)+a(1)+a(2)+a(3)+a(4);
process(a) begin
if x>2 then y<=’1’;
else y<=’0’;
end if;
end process;
end aa;
#include
sbit P10=P1^0;//表决人1
sbit P11=P1^1;//表决人2
sbit P12=P1^2;//表决人3
sbit P13=P1^3;//表决人4
sbit P14=P1^4;//表决人5
sbit P15=P1^5;//结果显示
int a=0;
int b=0;
int i=0;
void main()
{
while(1)
{
if(P10==0)
a++;
else
b++;
if(P11==0)
a++;
else
b++;
if(P12==0)
a++;
else
b++;
if(P13==0)
a++;
else
b++;
if(P14==0)
a++;
else
b++;
if(a>b)
P15=0;
else
P15=1;
a=b=0;
for(i=0;i<255;i++)
{}
}
}
#19696092355#
急求一道c语言程序设计题!多谢多谢!拜托了!设有5个学生的考试成 ******
#符甘# #include #define MAXLENGTH 20 #define MAXNUMBER 5 struct { int no; char name... for (i = 0; i %d student's information(no name math computer):", i + 1); scanf ("%d%...
#19696092355#
哪位高人知道三人表决器的程序怎么写,用汇编语言,谢了,有急用 - ******
#符甘# 这个简单,我来好了: ;;定义K1,2,3,4分别对应了P0.0,P0.1,P0.2,P1.0,PASS灯就定义在P3.0口吧,LED定义为高电平有效,key低电平有效,指示灯为P2.0 P2.1 P2.2;; OGR 0000H AJMP MAIN ;;主程序;; ORG 0010H MAIN:MOV P0,#0...
#19696092355#
(用c语言编写程序)有A、B、C、D、E 5人,每人额头上都贴了一张黑或白的纸. - ******
#符甘# #include int main(int argc, char *argv[])//可以写成int main(),没问题,个人习惯 { int a,b,c,d,e; for(a=0;a for(b=0;b for(c=0;c for(d=0;d for(e=0;e if((a&&b+c+d+e==3||!a&&b+c+d+e!=3) &&(b&&a+c+d+e==0||!b&&a+c+d+e!=0) &&(c&&a+b+d+e==1|...
#19696092355#
EDA编程9表决器 - ******
#符甘# //本程序用VERILOG HDL语言实现,描述9人表决器module biaojueqi(vote,ledr,ledg,dis_out);input [8:0] vote;output ledr,ledg;output [6:0] dis_out;reg [6:0] dis_out;integer i,sum; /...
#19696092355#
c语言编程57 - ******
#符甘# #include int main(){ int a,b,c,d,e; a=10; b=a+2; c=b+2; d=c+2; e=d+2; printf("5人年龄分别是:%3d%3d%3d%3d%3d",a,b,c,d,...
#19696092355#
VHDL语言编的13人表决器程序 - ******
#符甘# library ieee;use ieee.std_logic-1164.allentity bj13 isport(a:in std_logic_vector(0 to 12);b::out std_logic_vector(0 to1)):end bj13;architecture one of bj13 isbeginprocess(a)begincase a iswhen "00000000000" =>b<="10"...when others=>mull;end case;end process;end one;13位代表表决的人,高电平有效,b(0)为高电平为反对,b(1)为高电频为支持也可用for语句.
#19696092355#
(用c语言编写程序)有A、B、C、D、E 5人,每人额头上都贴了一张黑或白的纸. ******
#符甘# #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[])//可以写成int main(),没问题,个人习惯 { int a,b,c,d,e; for(a=0;a<=1;++a)//资深的程序员跟倾向于写成for(a=0;a!=2;a++)因为对电脑来说判断!=比<=更简单. ...
#19696092355#
C语言怎么才能每输出5个数据转行 - ******
#符甘# 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23#include<stdio.h> intmain() {inta,b,i,j=0; //j要初始化printf("输入a,b a<b\n");scanf("%d %d",&a,&b); for(i=a;i<=b;i++){if( i%400==0 || (i%4==0 && i%100!=0) )//添加花括...
#19696092355#
请用C语言设计程序实现将1、2、3、4、5、6、7、8、9、10? ******
#符甘# 我这个是键盘输入然后求和十进制显示的 ;这是自动生成的代码模板 STACKS ... PART5: POP DX MOV AH,2 INT 21H LOOP PART5 MOV AX,4C00H ;退出程序 INT 21H ...