[ create a new paste ] login | about

Link: http://codepad.org/fKY3ZOI5    [ raw code | output | fork ]

C, pasted on Jun 22:
#include <stdio.h>
#include <math.h>
int main (int argc, const char * argv[]) {

double a, b, c, x1, x2;
printf("ax^2+bx+c=0 の係数a,b,cは?");
scanf("%lf%lf%lf",&a,&b,&c);
if (a=0)
{printf("aには0を代入できません");}
if ((b*b-4*a*c) > 0)
{x1=(-b + sqrt(b*b-4*a*c))/(2*a);
x2=(-b - sqrt(b*b-4*a*c))/(2*a);
printf("x1=%lf\n",x1);
printf("x2=%lf\n",x2);}
if ((b*b-4*a*c) == 0)
{x1=(-b+sqrt(b*b-4*a*c))/(2*a);
printf("x1=%lf\n",x1);}
if ((b*b-4*a*c) < 0)
{x1=(-b/(2*a));
x2=(sqrt(b*b-4*a*c)/(2*a);
printf("x1=%lf+%lf",x1,x2);
printf("x2=%lf-%lf",x1,x2);
return 0;
}


Output:
1
2
3
4
In function 'main':
Line 20: error: expected ')' before ';' token
Line 24: error: expected ';' before '}' token
Line 24: error: expected declaration or statement at end of input


Create a new paste based on this one


Comments: