第三次作业

1.A

首先判断'a'与c的关系是相等,则‘a’<c为假,结果为0。而0<‘z',则c<='z'为真,进入if语句。

2.D

b+c为0,将0赋给a,则a=b+c为0,0为假,则不进入if语句,进入else语句

3.5

m++的值为m本身,m=5,进入else语句。同时产生副作用使m加一。m--的值为m本身,m=6,输出6

4.20 30 30

因为x<y,不进入if语句,不执行z=x。执行x=y,x为20,执行y=z,y为30。

5.1.&score

5.2.score/10

5.3.break

5.4.9

5.5.8

5.6.7

5.7.6

6.

#include <stdio.h>
 
int main()
{
    int year;
    scanf("%d",&year);
    if(0==year%400){
    	printf("%d年是闰年",year);
	}
    else{
    	printf("%d年不是闰年",year);
	}

   	return 0;	
}

 7.

#include <stdio.h>

int main()
{
    int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a>b){
		if(a>c&&b>c){
			printf("最大值:%d,最小值:%d",a,c);
		}
		if(a>c&&c>b){
			printf("最大值:%d,最小值:%d",a,b);
		}
	} 
	if(a<c&&b>a&&b>c){
		printf("最大值:%d,最小值:%d",b,a);
	}
	if(b>a&&b>c&&a>c){
		printf("最大值:%d,最小值:%d",b,c);
	}
	if(c>a&&c>b&&b>a){
		printf("最大值:%d,最小值:%d",c,a);
	}
	if(c>a&&c>b&&a>b){
		printf("最大值:%d,最小值:%d",c,b);
	}
	return 0;
}

 

 8.

#include <stdio.h>
int main(void)
{
	int a, b;
	char op;
	scanf("%d %c %d", &a, &op, &b);
	if(op=='+')
		printf("%d + %d = %d", a, b, a+b);
	if(op=='-')
		printf("%d - %d = %d", a, b, a-b);
	if(op=='*')
		printf("%d * %d = %d", a, b, a*b);
	if(op=='/')
		printf("%d / %d = %.6f", a, b, a*1.0/b*1.0);
	
	return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值