1043 想法有待实现
来源:互联网 发布:java equals int 编辑:程序博客网 时间:2024/06/04 18:55
//自己写一个排序,然后按照PPAATTeesstt
//直接写patest的排序然后输出
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <vector>
#include <sstream>
#include <iomanip>
#include <cmath>
#include<limits>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
string a;
cin>>a;
int len=a.length();
int b[6]={0};
sort(a.begin(),a.end());
for(int i=0;i<len;i++)
{
if(a[i]=='P') b[0]++;
else if(a[i]=='A') b[1]++;
else if(a[i]=='T') b[2]++;
else if(a[i]=='e') b[3]++;
else if(a[i]=='s') b[4]++;
else if(a[i]=='t') b[5]++;
}
int max = b[0];
for (int i = 1; i < 6; i++) {
if (b[i] > max) {
max = b[i];
}
}
for (int i = 0; i < max; i++)
{
if(b[0]!=0) {cout<<'P';b[0]--;}
if(b[1]!=0) {cout<<'A';b[1]--;}
if(b[2]!=0) {cout<<'T';b[2]--;}
if(b[3]!=0) {cout<<'e';b[3]--;}
if(b[4]!=0) {cout<<'s';b[4]--;}
if(b[5]!=0){ cout<<'t';b[5]--;}
}
return 0;
}
//直接写patest的排序然后输出
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <vector>
#include <sstream>
#include <iomanip>
#include <cmath>
#include<limits>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
string a;
cin>>a;
int len=a.length();
int b[6]={0};
sort(a.begin(),a.end());
for(int i=0;i<len;i++)
{
if(a[i]=='P') b[0]++;
else if(a[i]=='A') b[1]++;
else if(a[i]=='T') b[2]++;
else if(a[i]=='e') b[3]++;
else if(a[i]=='s') b[4]++;
else if(a[i]=='t') b[5]++;
}
int max = b[0];
for (int i = 1; i < 6; i++) {
if (b[i] > max) {
max = b[i];
}
}
for (int i = 0; i < max; i++)
{
if(b[0]!=0) {cout<<'P';b[0]--;}
if(b[1]!=0) {cout<<'A';b[1]--;}
if(b[2]!=0) {cout<<'T';b[2]--;}
if(b[3]!=0) {cout<<'e';b[3]--;}
if(b[4]!=0) {cout<<'s';b[4]--;}
if(b[5]!=0){ cout<<'t';b[5]--;}
}
return 0;
}
0 0
- 1043 想法有待实现
- 有待理解的 CI框架缓存的实现原理
- 一个难以实现的想法
- BTS Patch想法和实现
- 一些待实现的想法
- android 流量监控实现想法
- android 流量监控实现想法
- 实现WebRTC的几个想法
- HUSTOJ实现的相关想法
- 实现WebRTC的几个想法
- 实现WebRTC的几个想法
- 有待学习
- 有待学习
- 有待学习
- 不错,有待
- 有待解决
- 有待研究
- 想法
- RMQ算法
- DHCP服务器简介
- vim使用及配置策略
- 博为峰JavaEE技术文章 ——MyBatis BLOB字段
- Linux常用命令大全
- 1043 想法有待实现
- MySql (1267, "Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE)
- Tomcat系统架构分析
- (iOS-框架封装)AFN3.x 网络请求封装
- c++primer第十二章读书笔记
- SVN服务器的搭建
- 北航计算机机试13科学计数法
- Hello, JIT World: The Joy of Simple JITs
- java如何调用外部程序