#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
//GroupCount表示分组数,PerGroupCount表示每组
字符串个数
const int GroupCount=2,PerGroupCount=6;
string strarr[GroupCount*PerGroupCount];
string group[GroupCount][PerGroupCount];
int i=0,j,k;
srand(time(NULL));
cout<<"请输入"<<(GroupCount*PerGroupCount)<<"个字符串:"<<endl;
while(i<GroupCount*PerGroupCount)
cin>>strarr[i++];
for(k=j=i=0;k<GroupCount*PerGroupCount;k++)
{
//如果产生的
随机数是1且第1组分配的字符串未到6个,
//则将下标为k的字符串分给第1组
if(rand()%2&&i<PerGroupCount)
group[0][i++]=strarr[k];
else
group[1][j++]=strarr[k];
}
for(i=0;i<GroupCount;i++)
{
cout<<"第"<<(i+1)<<"组:"<<endl;
for(j=0;j<PerGroupCount;j++)
cout<<group[i][j]<<endl;
cout<<endl;
}
return 0;
}