传送门:https://www.luogu.org/problemnew/show/P1603

题意:

首先在给定的字符串中,找出特定的单词,把它转化成特定的数字,

然后在这些数字中,找出排列结果最小的一种排列;

思路:

第一步就是打表就ok,第二步,可以用字符串加法结果的大小进行排序;

遇到“找出所有排列方法中最小的一个数”,可能就要怎么做;

#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#define pb push_back
using namespace std;
typedef long long ll; vector<string>q;
bool cmp (string a,string b)
{
return a+b < b+a;
}
int main(){
string s;
while(cin>>s)
{
if(s=="one"||s=="a"||s=="another"||s=="first")q.pb("");
if(s=="two"||s=="both"||s=="second")q.pb("");
if(s=="three"||s=="third")q.pb("");
if(s=="four")q.pb("");
if(s=="five")q.pb("");
if(s=="six")q.pb("");
if(s=="seven")q.pb("");
if(s=="eight")q.pb("");
if(s=="nine")q.pb("");
if(s=="ten")q.pb("");
if(s=="eleven")q.pb("");
if(s=="twelve")q.pb("");
if(s=="thirteen")q.pb("");
if(s=="fourteen")q.pb("");
if(s=="fifteen")q.pb("");
if(s=="sixteen")q.pb("");
if(s=="seventeen")q.pb("");
if(s=="eighteen")q.pb("");
if(s=="nineteen")q.pb("");
if(s=="twenty")q.pb("");
//break;
if(s[s.length()-]=='.')break; }
sort(q.begin(),q.end(),cmp);
bool isout=false;
bool canout=false;
string a="";
for(int i=;i<q.size();i++)
a+=q[i];
for(int i=;i<a.length();i++)
{
if(a[i]!='') canout=true;
if(a[i]==''&&!canout)continue;
cout<<a[i];
isout=true;
}
if(!isout)cout<<"";
cout<<endl;
return ;
}

最新文章

  1. webpack+vue-cli项目打包技巧
  2. 【requireJS路径加载】与程序员小卡的交流
  3. sync_with_stdio
  4. jQuery.ajax()的相关参数及使用
  5. http://runjs.cn/
  6. Ta-lib 函数一览
  7. Hark的数据结构与算法练习之多路归并排序
  8. Maven Project configuration is not up-to-date with pom.xml错误解决方法
  9. DIV+CSS外部字体引用
  10. 优化viewHolder
  11. 使用element ui 日期选择器获取值后的格式问题
  12. ROS_Kinetic_12 ROS程序基础Eclipse_C++(三)usb camera
  13. Eclipse两种部署web项目方法
  14. Docker JDK镜像
  15. JavaScript 基础(一) - JavaScript的引入方式,JavaScript 变量命名规则,JS 的五种基本数据类型,ECMAScript 算数运算符,逻辑运算符
  16. Python在线聊天软件(Tkinter)
  17. 公用表表达式(CTE)
  18. 词云绘制wordcloud
  19. vs 15 key
  20. MongoDB学习笔记(11) --- 聚合

热门文章

  1. 理解SVG中的 viewport,viewBox, preserveAspectRatio
  2. 【Intellij】Hot Swap Failed &amp; class reloaded
  3. Mybatis整合Spring 使用
  4. Java集合系列(四):HashMap、Hashtable、LinkedHashMap、TreeMap的使用方法及区别
  5. Python - 自学django,上线一套资产管理系统
  6. React-Native之打包发布(Android)
  7. mybatis学习笔记(一)
  8. ASP.NET CORE系列【七】分析NetCore启动原理
  9. Go中的函数和闭包
  10. 为什么我们不用JIRA