谁能用C语言帮我写几个小程序 急求

来源:百度知道 编辑:UC知道 时间:2024/05/18 19:48:09
1 从键盘输入三个数,输出最大的
2 输入两个数,输出最大公约数和最小公倍数
3 输入一个年份,判断其是否为闰年
4 输入一个字母字符串,把其中的小写字母转换成大写字母
5 打印如下图案
?
? ? ?
? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ?
? ? ?
?

1、
#include<stdio.h>
int main()
{
int max(int x,int y,int z);
int a,b,c,d;
scanf("%d%d%d",&a,&b,&c); //scanf%d间不能有逗号,后面是输入的地址因此得加&
d=max(a,b,c); //输入的是abc,不是x,y,z//x,y,z是形参a,b,c是实参
printf("max=%d",d);//不是print是printf
return 0;
}
int max(int x,int y,int z)
{
return(x>y?(x>z?x:z):(y>z?y:z));
}

2、
#include<stdio.h>
int main()
{
int a,b,num1,num2,temp;
printf("Input a & b:");
scanf("%d%d",&num1,&num2);
if(num1>num2) /*找出两个数中的较大值*/
{
temp=num1; num1=num2; num2=temp; /*交换两个整数*/
}
a=num1; b=num2;
while(b!=0) /*采用辗转相除法求最大公约数*/
{
temp=a%b;
a=b;
b=temp;
}
printf("The GCD of %d and %d is: %d\n",num1,num2,a); /*输出最大公约数*/
printf("The LCM of them is: %d\n",num1*num2/a); /*输出最小公倍数*/
return 0;
}

3、
#include &