第一题
#include
#include
void asd1(int a,int b,int c)
{
printf("无解\n");
}
void asd2(int a,int b,int c)
{
double s;
s=-b*1.0/(2*a);
printf("x=%.2f\n",s);
}
void asd3(int a,int b,int c)
{
double s;
s=sqrt(b*b-4*a*c);
printf("x1=%.2f x2=%.2f\n",(-b+s)*1.0/(2*a),(-b-s)*1.0/(2*a));
}
int main()
{
int a,b,c;
while(scanf("%d%d%d",&a,&b,&c)!=EOF)
{
if(b*b-4*a*c<0)
asd1(a,b,c);
if(b*b-4*a*c==0)
asd2(a,b,c);
if(b*b-4*a*c>0)
asd3(a,b,c);
}
}
第五题
#include
void asd(int a)
{
int h,m,s;
h=a/3600;
a-=h*3600;
m=a/60;
a-=m*60;
s=a;
printf("%2d:%2d:%2d\n",h,m,s);
}
int main()
{
int a;
while(scanf("%d",&a)!=EOF)
{
asd(a);
}
}
第一题
#include
#include
void yishigen(float m,float n,float k)
{
float x1,x2;
x1=(-n+sqrt(k))/(2*m);
x2=(-n-sqrt(k))/(2*m);
printf("two shigen is x1=%.3f and x2=%.3f\n",x1,x2);
}
void denggen(float m,float n)
{
float x;
x=-n/(2*m);
printf("denggen is x=%.3f\n",x);
}
void xugen(float m,float n,float k)
{
float x,y;
x=-n/(2*m);
y=sqrt(-k)/(2*m);
printf("two xugen is x1=%.3f+%.3fi and x2=%.3f-%.3fi\n",x,y,x,y);
}
void main()
{
float a,b,c,q;
printf("input a b c is ");
scanf("%f,%f,%f",&a,&b,&c);
printf("\n");
q=b*b-4*a*c;
if(q>0) yishigen(a,b,q);
else if(q==0) denggen(a,b);
else xugen(a,b,q);
}
第二题是需要做一个电子时间表么?
#include
#include
#include
void main()
{
int hours=11,min=58,sec;
printf("输入秒sec:");
scanf("%d",&sec);
while(1)
{
sec++;
sec=sec%60;
if(sec==0)
min=(min+1)%60;//满60秒,分钟数+1
if(min==0&&sec==0)
hours=(hours+1)%24;//满60分,小时数+1
Sleep(1000);//延迟1000ms后输出
system("cls");//清屏
printf("%d:%d:%d",hours,min,sec);
}
}