PAT (Advanced Level) 1038. Recover the Smallest Number (30)
生活随笔
收集整理的這篇文章主要介紹了
PAT (Advanced Level) 1038. Recover the Smallest Number (30)
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
注意前導(dǎo)零的消去。
#include <iostream> #include <string> #include <sstream> #include <algorithm> using namespace std;string s[10000+10]; int n;bool cmp(const string &a, const string &b) {return a+b<b+a; }int main() {cin>>n;for(int i=1;i<=n;i++) cin>>s[i];sort(s+1,s+1+n,cmp);string ans;for(int i=1;i<=n;i++) ans=ans+s[i];int flag=0;for(int i=0;i<ans.size();i++){if(ans[i]!='0'){flag = 1;for(int j=i;j<ans.size();j++) cout<<ans[j];break;}}if(flag==0) cout<<"0";cout<<endl;return 0; }?
轉(zhuǎn)載于:https://www.cnblogs.com/zufezzt/p/5520968.html
總結(jié)
以上是生活随笔為你收集整理的PAT (Advanced Level) 1038. Recover the Smallest Number (30)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: js客户端存储之Web存储
- 下一篇: 开源Registry项目Harbor源代