69,371
社区成员
发帖
与我相关
我的任务
分享
<stdarg.h>
#define va_arg(ap,t) ( *(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )
#include <stdio.h>
#include <math.h>
void noroot(void)
float a,b,c,m;
void main()
{
printf("Input three index a,b,c please:\n");
scanf("%d,%d,%d",&a,&b,&c);
m=b*b-4*a*c;
if(m <0)
noroot();
else if(m> 0)
tworoots();
else oneroot();
}
void noroot(void)
{
printf("There is no root when m <0");
}
void oneroot()
{
float root=-b/(2*a);
printf("The root=%d",root);
}
void tworoots()
{
float roots1=((-b)+sqrt(m))/(2*a);
float roots2=((-b)-sqrt(m))/(2*a);
printf("The two roots are:roots1=%d,roots2=%d",roots1,roots2);
}
// test9.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdio.h>
#include <math.h>
float a,b,c,m;
void noroot(void)
{
printf("There is no root when m <0");
}
void oneroot()
{
float root=-b/(2*a);
printf("The root=%d",root);
}
void tworoots()
{
float roots1=( float )( ((-b)+sqrt(m))/(2*a) );
float roots2=( float )( ((-b)-sqrt(m))/(2*a) );
printf("The two roots are:roots1=%d,roots2=%d",roots1,roots2);
}
void main()
{
printf("Input three index a,b,c please:\n");
scanf("%f %f %f",&a,&b,&c);
m=b*b-4*a*c;
if(m <0)
noroot();
else if(m> 0)
tworoots();
else
oneroot();
}