33,317
社区成员
发帖
与我相关
我的任务
分享#include <iostream>
#include <vector>
using namespace std;
int main()
{
int n,T,m,place,temp;
size_t i,j,k = 0;
cout << "input the number of people( 0<=n<=20 ) and number of group(T)" << endl;
while ((cin >> n >> T) && (n < 0 || n > 20))
{
cout << " 0<=n<=20" << endl;
}
int peo[n-1],peonew[T-1][n-1];
vector<int> mm;
for (j = 0;j != n; ++j)
peo[j] = j + 1;
for (j = 0;j != n; ++j)
cout << peo[j] << " " ;
cout << endl;
cout << "input " << T << " groups of m( 0<=m<=100) " << endl;
for (i =0; i != T; ++i)
{
cin >> m;
mm.push_back(m);
}
vector<int>::size_type ix = 0;
for (i = 0;i != T; ++i )
{
place = mm[ix] % n;
++ix;
for (j = (n - place); j != n; ++j,++k)
{
temp = peo[j];
peonew[i][k] = temp;
}
for (j = 0,k = place; j != n - place; ++j,++k)
{
temp = peo[j];
peonew[i][k] = temp;
}
}
for (i = 0;i != T; ++i)
{
for (j =0;j != n; ++j)
cout << peonew[i][j] << " ";
cout << endl;
}
cout << endl;
return 0;
}