Home > Back-end >  C programming problem, requires the use of the STL containers
C programming problem, requires the use of the STL containers

Time:09-19

100 students a circle of cycle count off, in 9, ask students to ones with order

CodePudding user response:

1 to 100, in a list, to insert in turn into a list, and then simulate the number off, to 9,19,29... Elements to remove linked list, has been so simulation operation, remove each element of a print it number, the difficulty is to processing chain table cyclization,

CodePudding user response:

For example
 
#include
#include
using namespace std;
Int main (int arg c, const char * argv []) {
Int CNT=0, TMP;
List l;//the list to save student no.
.for (int i=0; i<100; I++) {
L.p ush_back (I + 1);
}
While (l.s considering () & gt; 0) {//if the student circles others have been circulating game
TMP=l.f ront ();//get the beginning of the row in the list of student no.
.L.p op_front ();//in the beginning of the list of student
Cnt++;//count off
If (% CNT==10 9 | | CNT % 100 & gt;=90 | | CNT % 1000 & gt;=900) {//if the number off a one thousand - bit arbitrary a nine is students to stand out from the queue is out
Count off: printf (" % d, out Numbers: % d \ n ", CNT, TMP);
} else {
L.p ush_back (TMP);//otherwise stand out and students continue to row at the end of the queue
}
}
return 0;
}
  • Related