各位大佬,我到底格式错哪了?
查看原帖
各位大佬,我到底格式错哪了?
289221
AliceGoretzka楼主2020/10/31 21:44
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t;
	
	while(cin>>t&&t!=0)
	{
		queue<int>cards;
		for(int i=1;i<=t;i++)
			cards.push(i);
	
		cout<<"Discarded cards: ";
		if(t==1)
			cout<<endl;
		while(t>2)
		{
			int temp=cards.front();
			cards.pop();
			cout<<temp<<", ";
			temp=cards.front();
			cards.pop();
			cards.push(temp);
			t--;
		}
		if(t==2)
		{
			int temp=cards.front();
			cout<<temp<<endl;
			cards.pop();
			t--;
		}
		if(t==1)
		{
			cout<<"Remaining card: ";
			cout<<cards.front()<<endl;
		}
		
	}
}
2020/10/31 21:44
加载中...