c++ 33分!大佬求助!!!
查看原帖
c++ 33分!大佬求助!!!
774204
A_chicken_boy楼主2023/1/23 11:10
#include <bits/stdc++.h>
using namespace std ;
int main ( )
{
	int t ;
	cin >> t ;
	for ( int i = 1 ; i <= t ; ++i )
	{
		int n ;
		cin >> n ;
		queue <int> q ;
		for ( int j = 1 ; j <= n ; ++j )
		{
			string s ;
		 	cin >> s ;
			if ( s[0] == 'p' && s[1] == 'u' )
			{
				int x ;
				cin >> x ;
				q.push ( x ) ;
			}
			else if ( s[0] == 'p' && s[1] == 'o' )
			{
				if ( q.empty ( ) )
				{
					cout << "Empty\n" ;
				}
				else q.pop ( ) ;
			}
			else if ( s[0] == 'q' )
			{
				if ( q.empty ( ) )
				{
					cout << "Anguei!" << endl ;
				}
				else 
				{
					int sb ;
					sb = q.front ( ) ;
					cout << sb << endl ;
				}
			}
			else if ( s[0] == 's' )
			{
				cout << q.size ( ) << "\n" ;
			}
		}
	}
	return 0 ;
}
2023/1/23 11:10
加载中...