私は数学に関する学校向けのプロジェクトを行っています。そのために、加算と減算を使用して乗算と除算を行う電卓を c++ で作成しています。両方の数値が小数である乗算を行うには助けが必要です。私のコードは次のようになります。
int divisionneeded;
int countuntilten;
countuntilten = 9;
while (b == (int)b)
{
countuntilten = 9;
temp = b;
while(countuntilten > 0){
b = b + temp;
countuntilten--;
cout << b << endl;
}
cout << "test" << endl;
divisionneeded++;
if(b == (int)b){
break;
}
//checkint is a library function
checkb = checkint(b);
}
cout << "Test" << endl;
temp = a;
count = b;
while(count>0)
{
a+=temp;
count--;
}
cout << a << endl;
while(divisionneeded>0)
{
countuntilten = 10;
while(countuntilten > 0){
countuntilten--;
}
cout << "TEst" << endl;
divisionneeded--;
}
ans = a;
cout << "TESt" << endl;
両方が小数の場合の乗算。プログラムが 3 番目の while ループでスタックしているように見えるので、助けが必要です。助けてください。