1编写一个C程序,输入a,b,c三个值,输出其中最大者*/
main()
{float a,b,c,max;
printf("please input three numbers:\n");
scanf("%f%f%f",&a,&b,&c);
if(a>=b) max=a;
else max=b;
if(max
printf("the max is: %f\n",max);
}
2两个瓶子分别装醋和酱油,要求互换,实际就是交换两变量*/
main()
{int a,b,t;
printf("please input two integer numbers:\n");
scanf("%d%d",&a,&b);
printf("before swap:a=%d,b=%d\n",a,b);
t=a; a=b; b=t;
printf("after swap:a=%d,b=%d\n",a,b);
}
3依次将10个数输入,要求打印其中最大的数*/
main()
{float num,max,n=1;
printf("please input a number:\n");
scanf("%f",&num);
max=num;
while(n<=9)
{printf("please input a number:\n");
scanf("%f",&num);
if (num>max) max=num;
n=n+1; }
printf("the max=%f\n",max);
}
4有3个数a,b,c,要求按大小顺序把它们打印出来*/
main()
{float a,b,c,t;
printf("please input three numbers:\n");
scanf("%f%f%f",&a,&b,&c);
printf("before sort:a=%g,b=%g,c=%g\n",a,b,c);
if(a>b) {t=a;a=b;b=t;}
if(a>c) {t=a;a=c;c=t;}
if(b>c) {t=b;b=c;c=t;}
printf("after sort:a=%g,b=%g,c=%g\n",a,b,c);
}
5有3个整数a,b,c,由键盘输入,输出其中最大的数*/
main()
{int a,b,c,max;
printf("please input three integer numbers:\n");
scanf("%d%d%d",&a,&b,&c);
if(a<=b) max=b;
else max=a;
if(max
printf("max=%d\n",max);
}
求1+2+3+...+100*/
main()
{int sum=0,i=1;
while(i<=100)
{sum=sum+i;
i=i+1;
}
printf("1+2+3+...+100=%d\n",sum);
}
6、/*判断一个数n能否同时被3和5整除*/
main()
{int n;
printf("please input a integer number:\n");
scanf("%d",&n);
if((n%3==0)&&(n%5==0)) printf("%d can be divided by both 3 and 5\n",n);
else printf("%d can't be divided by both 3 and 5\n",n);
}
7、将100到200之间的素数打印出来*/
#include "math.h"
main()
{int num=100,i,flag;
printf("the prime number from 100 to 200:\n");
while(num<=200)
{i=2;flag=0;
while(i<=sqrt(num))
{if(num%i==0) flag=1;
i=i+1; }
if(flag==0) printf("%4d",num);
num=num+1;
}
printf("\n");
}
8、/*求两个数m和n的最大公约数*/
main()
{int m,n,temp,answer;
printf("please input two integer numbers:\n");
scanf("%d%d",&m,&n);
if(m
{temp=m;m=n;n=temp;}
while(n!=0)
{temp=m%n;