コード例 #1
0
ファイル: xt7-2.c プロジェクト: hclife/linux-bash
int main()
{void greater_than_zero(float,float);
 void equal_to_zero(float,float);
 void smaller_than_zero(float,float);
 float a,b,c;
 printf("input a,b,c:");
 scanf("%f,%f,%f",&a,&b,&c);
 printf("equation: %5.2f*x*x+%5.2f*x+%5.2f=0\n",a,b,c);
 disc=b*b-4*a*c;
 printf("root:\n");
 if (disc>0)
  {
   greater_than_zero(a,b);
   printf("x1=%f\t\tx2=%f\n",x1,x2);
  }
 else if (disc==0)
  {equal_to_zero(a,b);
   printf("x1=%f\t\tx2=%f\n",x1,x2);
  }
 else
  {smaller_than_zero(a,b);
   printf("x1=%f+%fi\tx2=%f-%fi\n",p,q,p,q);
  }
 return 0;
}
コード例 #2
0
ファイル: main.c プロジェクト: m-wichmann/libConCoCt
int main(void)
{
    int ret = 0;
    
    ret = greater_than_zero(2);
    assert(ret == 1);
    
    ret = greater_than_zero(42);
    assert(ret == 1);
    
    ret = greater_than_zero(-17);
    assert(ret == 0);
    
    ret = greater_than_zero(0);
    assert(ret == 0);
    
    return 0;
}
コード例 #3
0
ファイル: test.c プロジェクト: m-wichmann/libConCoCt
static void test_positive_numbers(void)
{
    CU_ASSERT(greater_than_zero(3) == 1);
    CU_ASSERT(greater_than_zero(42) == 1);
    CU_ASSERT(greater_than_zero(2000000000) == 1);
}
コード例 #4
0
ファイル: test.c プロジェクト: m-wichmann/libConCoCt
static void test_negative_numbers(void)
{
    CU_ASSERT(greater_than_zero(-3) == 0);
    CU_ASSERT(greater_than_zero(-2000000000) == 0);
    CU_ASSERT(greater_than_zero(-1) == 0);
}
コード例 #5
0
ファイル: test.c プロジェクト: m-wichmann/libConCoCt
static void test_zero(void)
{
    CU_ASSERT(greater_than_zero(0) == 0);
}