C言語で簡単な計算機コードを実現する
5132 ワード
#include
#include
#include
//
int main(void)
{
double bNumber, Number, Result; //
int No; //
double a, b, c, x1, x2, Rad; //
int Ary_10; //
char string[32]; //
system ("title —— By:HaGit"); //
while(1)
{
//
printf ("┏ ┅ ┅ ┅ ┅ ┅ ┅ ┅ ┅ ┅ ┅ ┅ ┅ ┅ ┅ ┅ ┓
");
printf ("┇ : ┇
");
printf ("┣ ┅ ┅ ┅ ┅ ┅ ┅ ┅ ┅ ┅ ┅ ┅ ┅ ┅ ┅ ┅ ┫
");
printf ("┇ _1 _5 ┇
");
printf ("┇ _2 _6 ┇
");
printf ("┇ _3 ┇
");
printf ("┇ _4 _0 ┇
");
printf ("┗ ┅ ┅ ┅ ┅ ┅ ┅ ┅ ┅ ┅ ┅ ┅ ┅ ┅ ┅ ┅ ┛
");
printf ("Please write down the number:");
scanf ("%d",&No);
if (No == 1)
{
//
printf (" :");
scanf ("%lf",&bNumber);
printf (" :");
scanf ("%lf",&Number);
Result = bNumber + Number;
printf (" : %lf
",Result);
}
else if (No == 2)
{
//
printf (" :");
scanf ("%lf",&bNumber);
printf (" :");
scanf ("%lf",&Number);
Result = bNumber - Number;
printf (" : %lf
",Result);
}
else if (No == 3)
{
//
printf (" :");
scanf ("%lf",&bNumber);
printf (" :");
scanf ("%lf",&Number);
Result = bNumber * Number;
printf (" : %lf
",Result);
}
else if (No == 4)
{
//
printf (" :");
scanf ("%lf",&bNumber);
printf (" :");
scanf ("%lf",&Number);
Result = bNumber / Number;
printf (" : %lf
",Result);
}
else if (No == 5)
{
//
printf(" :");
scanf("%d", &Ary_10);
itoa (Ary_10, string ,2);
printf(" : %s
", &string);
printf(" : %o
", &Ary_10);
printf(" : %x
", &Ary_10);
}
else if (No == 6)
{
//
printf(" a,b,c :");
scanf("%lf%lf%lf",&a,&b,&c);
Rad = b*b - 4*a*c;
if (Rad > 0)
{
x1 = -b + sqrt(Rad) / (2*a);
x2 = -b - sqrt(Rad) / (2*a);
printf(" x1 = %lf, x2 = %lf
", &x1, &x2);
}
else if (Rad == 0)
{
x1 = -b / (2*a);
printf(" x1 = %lf
", &x1);
}
else
{
printf("
");
}
}
else if (No == 0)
{
//
break;
}
else
{
//
printf(" 。
");
}
system ("pause"); //
system ("cls"); //
}
return 0;
getchar();
}
C言语で简単な计算机コードを実现して、みんなに指导することを望みます......