Data Report for children
| Time limit:1000 ms |
|
Memory limit:65536 K |
| Total submissions:9883 |
|
Accepted:4597 |
Description
There are n Children in a circle and number them in sequence from 1. Now the number is specified to start from W. When the number is reported to S, the child is listed, next, report the number from the next child, and report the number of S columns. Repeat this until all the children are listed (if the total number is less than S, report the number cyclically.
Input
Number of children in the first line n (n <= 64)
Next, enter the name of a child in each line (the name cannot exceed 15 characters)
Enter W, S (W <n) in the last line, and separate them with commas (,).
Output
Output by person name the children are listed in order, and each row outputs a person's name
Sample Input
5XiaomingXiaohuaXiaowangZhangsanLisi2,3
Sample output
ZhangsanXiaohuaXiaomingXiaowangLisi
Source
This is an entry-level question of Joseph's question. It is an application of linear tables,
However, the compile error is reported several times in poj today;
The idea is to output the name after reporting the number to this position, and then move the subsequent sequence number one by one;
# Include <cstdio> # include <cstring> # include <iostream> using namespace STD; int main () {string name [65]; // storage name int N, W, s, index [65]; scanf ("% d", & N); For (INT I = 0; I <n; I ++) {CIN> name [I]; index [I] = I; // store the serial number of each child's location} scanf ("% d", & W, & S); W = (W + N-1) % N; // do {W = (W + s-1) % N; cout <name [index [w] <Endl; For (INT I = W; I <n-1; I ++) // move the following element forward to an index [I] = index [I + 1];} while (-- N); Return 0 ;}