51nod 1097 拼成最小的数
来源:互联网 发布:不规则体积计算软件 编辑:程序博客网 时间:2024/06/11 17:52
题目链接:传送门
用结构体存字符,然后重载cmp进行比较,怎么个比较法呢?
学到一个超牛逼的方法就是cmp里面定义
if(x.a+y.a
#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>#include<cmath>using namespace std;#define N 10100struct rng{ string a; int len;}t[N];char b[N*9];bool cmp(rng x,rng y){ if(x.a+y.a<y.a+x.a) return 1; return 0;}int main(){ int i,j,n,m,k; int len1; while(scanf("%d",&n)!=EOF){ for(i=1;i<=n;i++){ cin>>t[i].a; } sort(t+1,t+1+n,cmp); int cnt=0; for(i=1;i<=n;i++){ len1=(t[i].a).size(); for(j=0;j<len1;j++){ cout<<t[i].a[j]; cnt++; if(cnt==1000){ cout<<endl; cnt=0; } } } cout<<endl; } return 0;}
0 0
- 51NOD 1097 拼成最小的数
- 51nod 1097 拼成最小的数
- 51nod 1097 拼成最小的数
- 51Nod 1097 拼成最小的数
- 51nod 1097 拼成最小的数
- 51nod 1097 拼成最小的数
- 51nod 1097 拼成最小的数
- 51nod 1097 拼成最小的数 (排序)
- 51Nod-1097-拼成最小的数
- 51 nod 1097 拼成最小的数 思路:字符串排序
- 51nod 1097 拼成最小的数 思维
- 51nod 1097 拼成最小的数 【简单排序】
- 51Nod 1097 拼成最小的数 排序
- 51nod oj 1097 拼成最小的数 【贪心-结构体sort排序】
- 51nod 1097 拼成最小的数 思维题 t1+t2<t2+t1
- 1097 拼成最小的数
- 拼成最小的数
- 拼成最小的数
- linux 服务的启动和管理
- 防止搬瓦工被封的注意事项
- 22 IO流-字符流、缓冲字符流、递归
- redis和memcached工作原理
- SequenceInputStream(序列流)和对象的输入输出流
- 51nod 1097 拼成最小的数
- hashCode()和equals()重写
- Android7.0解析Init.rc文件
- j2se(一)_Number 类Integer、Long、Byte、Double、Float、Short
- android 字符串中的\n 直接显示,不会换行
- 【nodejs】http加载静态文件
- 【算法分析】回溯法解数独(九宫格)算法
- R语言基础画图/绘图/作图
- APP的主题背景风格