蒟蒻不知道错哪了
查看原帖
蒟蒻不知道错哪了
246822
Yhlo_Yzj楼主2021/10/9 19:50
#include<bits/stdc++.h>
using namespace std;
int s,m,l,xl,xxl;
int k;
int main(){
	cin>>s>>m>>l>>xl>>xxl;
	cin>>k;
	string str;
	for(int i=0;i<k;i++){
		cin>>str;
		if(str=="S"){
			if(s!=0){
				cout<<"S"<<endl;
				s--;
			}else{
				if(m!=0){
					cout<<"M"<<endl;
					m--;
				}else{
					if(l!=0){
						cout<<"L"<<endl;
						l--;
					}else{
						if(xl!=0){
							cout<<"XL"<<endl;
							xl--;
						}else{
								cout<<"XXL"<<endl;
								xxl--;
						}
					}
				}
			}
		}
		else if(str=="M"){
			if(m!=0){
				cout<<"M"<<endl;
				m--;
			}else{
				if(l!=0){
					cout<<"L"<<endl;
					l--;
				}else{
					if(s!=0){
						cout<<"S"<<endl;
						s--; 
					}else{
						if(xl!=0){
							cout<<"XL"<<endl;
							xl--;
						}else{
							cout<<"XXL"<<endl;
							xxl--;
						}
					}
				}
			}
		}
		else if(str=="L"){
			if(l!=0){
				cout<<"L"<<endl;
				l--;
			}else{
				if(xl!=0){
					cout<<"XL"<<endl;
					xl--;
				}else{
					if(m!=0){
						cout<<"M"<<endl;
						m--;
					}else{
						if(xl!=0){
							cout<<"XXL"<<endl;
							xxl--;
						}else{
							cout<<"S"<<endl;
							s--;
						}
					}
				}
			}
		}
		else if(str=="XL"){
			if(xl!=0){
				cout<<"XL"<<endl;
				xl--;
			}else{
				if(xxl!=0){
					cout<<"XXL"<<endl;
					xxl--;
				}else{
					if(l!=0){
						cout<<"L"<<endl;
						l--;
					}else{
						if(m!=0){
							cout<<"M"<<endl;
							m--;
						}else{
							cout<<"S"<<endl;
							s--;
						}
					}
				}
			}
		}
		else if(str=="XXL"){
			if(xxl!=0){
				cout<<"XXL"<<endl;
				xxl--;
			}else{
				if(xl!=0){
					cout<<"XL"<<endl;
					xl--;
				}else{
					if(l!=0){
						cout<<"L"<<endl;
						l--;
					}else{
						if(m!=0){
							cout<<"M"<<endl;
							m--;
						}else{
							if(s!=0){
								cout<<"S"<<endl;
								s--;
							}
						}
					}
				}
			}
		}
	}
	return 0;
}

2021/10/9 19:50
加载中...