正在加载图片...
(4)b>a&&c>b(5)a&&dc (6)!a&&b>c (7)(b>a)llc<b (8)all d-c (9)la‖cd (10)(al|b)&&c<b(l11)(a&&d)&&c(12)la&c>d 解: (1)0 (2)0 (3)0 (4)0 (5)0 (6)0 (7)0 (9)1 (11)0 (12) 3.8参考教材标准输入输出格式的规定,测试几组数据,看看执行情况如何。 (略 39写出下面程序的输出结果并上机验证 (1)#include<stdio. h> for(i=0,x>5;y=++1) (2)#include<stdio. h> inta=-13,b=-4, printf("%d printf("%d ",a%-b) 解:(1)8107162 (2)-111-1 3.10编写程序,从键盘上输入两个电阻的值,求它们并联和串联的电阻值,输出结果 保留两位小数。 解:本题的输入输出要求很明确,并联和串联的电阻值计算公式如下: R1+R2 并联电阻RP= 串联电阻RS=R+R2 R1*R2 用顺序结构即可完成题目要求的任务,程序如下: #includestdio h I float rl, r2, rp, rs printf("Input Rl and R2: " scanf (%f %f", &rl, &r2)(1)a>=b (2)c-b==a (3)c!=d-b (4)b>a && c>b (5)a && d-c (6)!a && b>c (7)(b>a) || c<b (8)a || d-c (9)!a || c>d (10)(a||b) && c<b (11)(a && d) && c (12)!a && c>d 解: (1)0 (2)0 (3)0 (4)0 (5)0 (6)0 (7)0 (8)1 (9)1 (10)0 (11)0 (12)1 3.8 参考教材标准输入输出格式的规定,测试几组数据,看看执行情况如何。 (略) 3.9 写出下面程序的输出结果并上机验证。 (1) #include<stdio.h> main() { int x=8, y=10,i; for (i=0;x>5; y=++i) printf(" %d %d ",x--,y); } (2) #include<stdio.h> main() { int a=-13, b=-4; printf("%d ",a%b); printf("%d " ,-a % -b ); printf("%d ",-a%b ); printf("%d ",a%-b ); } 解: (1)8 10 7 1 6 2 (2)-1 1 1 -1 3.10 编写程序,从键盘上输入两个电阻的值,求它们并联和串联的电阻值,输出结果 保留两位小数。 解:本题的输入输出要求很明确,并联和串联的电阻值计算公式如下: 并联电阻 RP= 1* 2 1 2 R R R + R 串联电阻 RS=R1+R2 用顺序结构即可完成题目要求的任务,程序如下: #include<stdio.h> main() { float r1,r2,rp,rs; printf("Input R1 and R2:"); scanf("%f %f",&r1,&r2);
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有