L1-023 输出GPLT
作者:互联网
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <cctype>
using namespace std; #define maxn 3000
int main() { int check[4]={0},mark=0; char b[4]={'G','P','L','T'}; string s;cin >>s; transform(s.begin(),s.end(),s.begin(),::toupper); for (int i = 0; i < s.size(); i++) for (int k = 0; k <= 3; k++) if(s[i] == b[k]) check[k]++; for (int i = 0; i <= 3; i++)if(check[i]) mark++; while(mark) { for (int i = 0; i <= 3; i++) if(check[i]) { check[i]--; cout<<b[i]; if(check[i] == 0) mark--; } } return 0; }
using namespace std; #define maxn 3000
int main() { int check[4]={0},mark=0; char b[4]={'G','P','L','T'}; string s;cin >>s; transform(s.begin(),s.end(),s.begin(),::toupper); for (int i = 0; i < s.size(); i++) for (int k = 0; k <= 3; k++) if(s[i] == b[k]) check[k]++; for (int i = 0; i <= 3; i++)if(check[i]) mark++; while(mark) { for (int i = 0; i <= 3; i++) if(check[i]) { check[i]--; cout<<b[i]; if(check[i] == 0) mark--; } } return 0; }
标签:begin,int,mark,++,023,L1,GPLT,include,check 来源: https://www.cnblogs.com/TigerDZ/p/11728112.html