赞
踩
#include <stdio.h>
main()
{
double n;
printf("input:");
scanf("%lf",&n);
printf("%d,%f\n",(int)n,n-(int)n);
}
#include <stdio.h>
main()
{
double n;
int m;
printf("input:");
scanf("%lf",&n);
m=n;//3.14
printf("%d,%f\n",m,n-m);
}
#include <stdio.h>
main()
{
float a,b,c,m;
printf("input:");
scanf("%f%f%f",&a,&b,&c);
m=a<=b?a:b;
if(c<m)
m=c;
printf("m=%f\n",m);
}
#include <stdio.h>
float min(float,float,float);
main()
{
float a,b,c,m;
printf("input:");
scanf("%f%f%f",&a,&b,&c);
m=min(a,b,c);
printf("m=%f\n",m);
}
float min(float a,float b,float c)
{
int m;
m=a<=b?a:b;
if(m<c)
return m;
}
#include <stdio.h>
main()
{
int a,b,s1=0,s2=0,i;
printf("input:");
scanf("%d%d",&a,&b);
for(i=a;i<=b;i++)
if(i%2==1)
s1+=i;
else
s2+=i;
printf("s1=%d,s2=%d\n",s1,s2);
}
#include <stdio.h>
#include <math.h>
/*
4、使用以下公式计算π,要求精度<1-5.
π/4=1/1-1/3+1/5-1/7+...+(-)1/n
*/
main()
{
double pi=0,p=1,s=1,i=1;
while(fabs(p)>1e-5)
{
pi+=p;
s=-s;
i+=2;
p=s/i;
}
pi*=4;
printf("pi=%f\n",pi);
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。