7月4日作业 DAY 4

1.代码:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, const char *argv[])
{
    double a, b,temp;
    printf("输入两个数,从小到大输出\n");
    printf("请输入两个数:");
    scanf("%lf %lf",&a,&b);
    if(a > b)
    {
        temp = b;
        b = a;
        a = temp;
        printf("%lf %lf\n",a,b);
    }
    else
    {
        printf("%lf %lf\n",a,b);
    }
    
	return 0;
}

 结果:

2.代码

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, const char *argv[])
{
	double a,b,c,max;
    printf("输入三个数,输出最大值\n");
	printf("请输入三个数\n");
	scanf("%lf %lf %lf",&a,&b,&c);
	if(a>b)
	{
		max = a;
	}
	else
	{
		max = b;
	}
	
	if(max > c)
		{
			printf("最大值为%lf\n",max);
		}
	else
	{
		max = c;
		printf("最大值为%lf\n",max);
	}	
	return 0;
}

 结果:

3.代码:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, const char *argv[])
{
	printf("请输入一个字符:\n");
	char c = getchar();
	if(c >= 'A' && c <= 'Z')
	{
		c = c + 32;
		printf("字符转小写为:%c\n",c);
	}
	else if(c >= 'A' && c <= 'Z')
	{
		c = c - 32;
		printf("字符转大写为:%c\n",c);
	}
	else if(c >= '0' && c <= '9')
	{
		c = c -'0';
		c = c*c;
		printf("该数字平方为:%d\n",c);
	}
	else if(c < 0 || c> 127)
	{
		printf("输入的不是字符!\n");
	}
	else
	{
		printf("这是特殊字符\n输出原字符:%c\n",c);
	}
	
	return 0;
}

 结果:

 4.思维导图

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值