1、输入任意两个数,请从小到大输出
#include <stdio.h>
#include <string.h>
int main(int argc, const char *argv[])
{
int a,b;
printf("请输入两个数:");
scanf("%d %d",&a,&b);
if(a<b)
printf("%d %d",a,b);
else
{
a=a+b;
b=a-b;
a=a-b;
printf("%d %d",a,b);
}
return 0;
}
【输入样例】
55 24
【输出样例】
24 55
2、计算三个数的最大值
#include <stdio.h>
#include <string.h>
int main(int argc, const char *argv[])
{
int a,b,c;
int max;
printf("请输入三个数:");
scanf("%d %d %d",&a,&b,&c);
max=a;
if(max<b)
max=b;
if(max<c)
max=c;
printf("%d是最大值\n",max);
return 0;
}
【输入样例】
55 8 23
【输出样例】
55是最大值
3、输入一个字符如果是大写转换小写,如果是小写转换大写,如果是数字输出平方,如果是特殊字符则直接输出
#include <stdio.h>
#include <string.h>
#include <math.h>
int main(int argc, const char *argv[])
{
char c;
printf("请输入一个字符:");
scanf("%c",&c);
if(c>='A'&&c<='Z')
printf("%c",c+32);
else if(c>='a'&&c<='z')
printf("%c",c-32);
else if(c>='0'&&c<='9')
printf("%.0f",pow(c-'0',2));
else
printf("%c",c);
return 0;
}
【输入样例】
a
【输出样例】
A
【输入样例】
A
【输出样例】
a
【输入样例】
9
【输出样例】
81
【输入样例】
`
【输出样例】
`