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.思维导图