Home > Back-end >  After the operation how to enter infinite loop?
After the operation how to enter infinite loop?

Time:03-25

Such as: N individuals in a circle number off, report to the digital exit number, exit, the remaining people continue, until the last remaining person, code is as follows:

# include & lt; Iostream>
# include & lt; Iomanip>
using namespace std;
Int main ()
{int a, [100].
int i;
Int call_no;
Int end_no;
Int leave_no;
Int end_dig leave_dig;
Int cycl_total;
Cout<" Please enter the total number of: ";
Cin> End_no;
for(i=0; ICoutCout<" Please enter a number: to leave ";
Cin> Leave_no;
CoutCall_no=1;
Cycl_total=end_no;
Do//count off
{end_dig=0;//count off the counter
While (call_no & lt;=end_no)
{if (a [] call_no - 1!=0)
{end_dig + +;//a, counter + 1
If (end_dig==leave_no) a [] call_no - 1=0;//counter to exit the number, the location data reset
}
If (call_no==end_no) call_no=1;//count off to the last, from the first to
If (end_dig==end_no) break;//count off to the original, total number off to complete a circle
}
Cycl_total -;
} while (cycl_total & gt; 1);//each circle number off to leave a person, the last remaining a, the number of total number off lap circle to end - 1
for(i=0; ICoutreturn 0;
}

Run time as a result, into an infinite loop, a great god help, where is wrong?
  • Related