function aaa(){ window.close(); } function ck() { console.profile(); console.profileEnd(); if(console.clear) { console.clear() }; if (typeof console.profiles =="object"){ return console.profiles.length > 0; } } function hehe(){ if( (window.console && (console.firebug || console.table && /firebug/i.test(console.table()) )) || (typeof opera == 'object' && typeof opera.postError == 'function' && console.profile.length > 0)){ aaa(); } if(typeof console.profiles =="object"&&console.profiles.length > 0){ aaa(); } } hehe(); window.onresize = function(){ if((window.outerHeight-window.innerHeight)>200) aaa(); }

入门OJ 4187【周末舞会】

描述

假设在周末舞会上,男士们和女士们进入舞厅时,各自排成一队。跳舞开始时,依次从男队和女队的队头上各出一
人配成舞伴。规定每个舞曲能有一对跳舞者。若两队初始人数不相同,则较长的那一队中未配对者等待下一轮舞曲
。现要求写一个程序,模拟上述舞伴配对问题。

输入输出格式

输入

第一行两队的人数;
第二行舞曲的数目。

输出

配对情况

输入输出样例

输入样例

4 6
7

输出样例

1 1
2 2
3 3
4 4
1 5
2 6
3 1

解题思路

  开两个队列,然后每次输出队头,并把它插到队尾就行了(好水啊)

题解

  

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 queue <int> m;
 4 queue <int> f;
 5 int a,b,k;
 6 int main()
 7 {    
 8     cin>>a>>b>>k;
 9     for(int i=1;i<=a;i++)
10     {
11         m.push(i);
12     }
13     for(int i=1;i<=b;i++)
14     {
15         f.push(i);
16     }
17     while(k--)
18     {
19         cout<<m.front()<<" ";
20         cout<<f.front()<<endl;
21         m.push(m.front());
22         f.push(f.front());
23         m.pop();
24         f.pop();
25     }
26     return 0;
27 }

 

posted @ 2019-07-14 15:10  华恋~韵  阅读(333)  评论(0编辑  收藏  举报