c语言在线翻译

发布网友 发布时间:2022-04-23 21:36

我来回答

2个回答

热心网友 时间:2022-04-27 10:21

/包涵头文件stdio.h
void main//返回空值的main函数
{
float a,b,c,x;//定义浮点类型a,b,c,x
x=0;//给x赋初值0

printf("a=");//在屏幕上输出 a=
scanf("%f",&a);//从键盘上获取一个浮点数赋给a
printf("b=");//在屏幕上输出 a=
scanf("%f",&b);//从键盘上获取一个浮点数赋给b
printf("c=");//在屏幕上输出 a=
scanf("%f",&f);//从键盘上获取一个浮点数赋给f
/*这句是不是有问题?应该是scanf("%f",&c);吧?*/

x=a/(b-c);//将a/(b-c)的值赋给x

if((b-c)!=0)//假如(b-c)不等于0
print("%.2f=a/(b-c)\n",x);//在屏幕上输出(x的值,保留两位小数)=a/(b-c)(一个回车符)
else//否则
{
printf("\nError!\n");//在屏幕上输出(一个回车符)Error!(一个回车符)
}
}

热心网友 时间:2022-04-27 11:39

#include <reg52.h>
#包括<< reg52。”
#define uint unsigned int
# unsigned int定义单元
#define uchar unsigned char
#定义unsigned char函数
sbit RED_A = P2^0;
公司red_a = P2 ^ 0;
sbit YELLOW_A = P2^1;
公司yellow_a = P2 ^ 1;
sbit GREEN_A = P2^2;
公司green_a = P2 ^ 2;
sbit RED_B = P2^3;
公司red_b = P2 ^ 3;
sbit YELLOW_B = P2^4;
公司yellow_b = P2 ^ 4;
sbit GREEN_B = P2^5;
公司green_b = P2 ^ 5;
uchar Count = 0,Flash_Count = 0,Operation_Type = 1;
函数数= 0,flash_count = 0,operation_type = 1;
void T0_INT() interrupt 1
无效t0_int()中断1
{
{
TH0=(65536-50000)/256;
TH0 =(65536-50000)/ 256;
TL0=(65536-50000)%256;
TL0 =(65536-50000)% 256;
switch(Operation_Type)
开关(operation_type)
{
{
case 1:
案例1:
RED_A=1;YELLOW_A=1;GREEN_A=0;
red_a = 1;yellow_a = 1;green_a = 0;
RED_B=0;YELLOW_B=1;GREEN_B=1;
red_b = 0;yellow_b = 1;green_b = 1;
if(++Count != 100) return;
如果(+ +计数!= 100)返回;
Count=0;
计数= 0;
Operation_Type = 2;
operation_type = 2;
break;
打破;
case 2:
案例2:
if(++Count != 8) return;
如果(+ +计数!= 8)返回;
Count=0;
计数= 0;
YELLOW_A=!YELLOW_A;
yellow_a =!yellow_a;
GREEN_A=1;
green_a = 1;
if(++Flash_Count != 10) return;
如果(+ + flash_count!= 10)返回;
Flash_Count=0;
flash_count = 0;
Operation_Type = 3;
operation_type = 3;
break;
打破;
case 3:
案例3:
RED_A=0;YELLOW_A=1;GREEN_A=1;
red_a = 0;yellow_a = 1;green_a = 1;
RED_B=1;YELLOW_B=1;GREEN_B=0;
red_b = 1;yellow_b = 1;green_b = 0;
if(++Count != 100) return;
如果(+ +计数!= 100)返回;
Count=0;
计数= 0;
Operation_Type = 4;
operation_type = 4;
break;
打破;
case 4:
案例4:
if(++Count != 8) return;
如果(+ +计数!= 8)返回;
Count=0;
计数= 0;
YELLOW_B=!YELLOW_B;
yellow_b =!yellow_b;
GREEN_B=1;
green_b = 1;
if(++Flash_Count !=10)
如果(+ + flash_count!= 10)
return;
返回;
Flash_Count=0;
flash_count = 0;
Operation_Type = 1;
operation_type = 1;
break;
打破;
}
}
}
}
void main()
无效main()
{
{
TMOD = 0x01;
TMOD = 0x01;
TH0=(65536-50000)/256;
TH0 =(65536-50000)/ 256;
TL0=(65536-50000)%256;
TL0 =(65536-50000)% 256;
IE = 0x82;
IE = 0x82;
TR0 = 1;
tr0 = 1;
while(1);
而(1);
}
}

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com