スニペットの最後にint duplicate = num
がどのように使用されているのか、またnum = duplicate
がわかりました。このスニペットで「int duplicate = num」はどのように使用されていますか?
int even(int num, ofstream& fileout) //This function will calculate the even digits
{ int remainder; //This variable holds the division of the number by 10.
int reverse = 0; //This will hold the reverse number.
bool flag = false; //Boolean variable.
int duplicate = num;
while(num > 0)
{
remainder= num%10;
if((remainder) % 2 == 0) //This condition will validate equality to zero when divided by 2. If this is the case ten even numbers
flag = true;
num /= 10;
}
num = duplicate;
'while'ループの後に' num'の元の値を使用する場合はどうなりますか? – PaulMcKenzie
コードの最後の行が欠落しています。 –
誰も 'num = duplicate;'と答えることはできません。実際には関数の終了がありません。それは絶対に何もしないかもしれません。 – user4581301