/*
       -= SEER - C-Scripting engine v 0.93a =-
State      : under implementation
Author     : Przemyslaw Podsiadly
             email: ppodsiad@elka.pw.edu.pl
             WWW:   http://home.elka.pw.edu.pl/~ppodsiad
File:exsimple.sc
Desc:simple script example:printf & scanf,doubles
*/
#title "ExSimple"

//here we tell, that 'main' funciton can be called from the main program
//The 'main' function has arguments, but we don't list them here.
export main;

//here we tell, that we use external function printf and others...
import int printf(char *,...);
import int scanf(char *,...);
import int isqrt(int);
import double sqrt(double);

int main(char *x)
{
 double a,b,c;

//we use imported functions
 printf(x);
 printf("\n");
 printf("a=");scanf("%lf",&a);
 printf("b=");scanf("%lf",&b);
 printf("c=");scanf("%lf",&c);
 printf("%f*xý+%f*x+%f=0 has \n",a,b,c);

//we can define variables alike in C++, so we don't have to do it at the 
//very begining of the {} block.
 double delta=b*b-4*a*c;

 if (a==0)
    {if (b==0)
        {
          if (c==0)
             printf("infinite number of results");
             else
             printf("no results");
          return 0;
        }
     else
        {
          printf("x=%f\n",-c/b);
          delta=0;//make it as 1 result
        }
    }
     else
    {
     if (delta<0)
       {
       }
     else
       {
       if (delta==0)
          {
           printf("x=%f\n",-b/(2*a));
          }
       else
          {
           printf("x1=%f\n",(-b-sqrt(delta))/(2*a));
           printf("x2=%f\n",(-b+sqrt(delta))/(2*a));
          }
       }
    }
 printf(" %s result%s\n",delta<0?"no":(delta>0?"2":"1"),delta!=0?"s":" ");
//and exit
 return 0;
}


