poj1007——DNA Sorting
2011-03-29 22:28
465 查看
发现喜欢用上了sort!操作简单、方便。
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; class str { public: char a[60]; int cout; str() { cout=0; } }; str g[110]; bool cmp(str &a,str &b) { if(a.cout<=b.cout ) return true; return false; } int main() { int len,m,i,j,k; cin>>len>>m; for(i=0;i<m;i++) { scanf("%s",&g[i].a ); g[i].cout =0; for(j=0;j<len-1;j++) for(k=j+1;k<len;k++) if(g[i].a [j]>g[i].a [k]) g[i].cout ++; } sort(g,g+m,cmp); for(i=0;i<m;i++) printf("%s/n",g[i].a ); return 0; }
相关文章推荐
- POJ 1007 DNA Sorting
- poj1007——DNA Sorting
- 算法:POJ1007 DNA sorting
- POJ 1007 DNA Sorting
- [POJ][1007]DNA Sorting
- POJ-1007 DNA Sorting
- poj 1007 DNA Sorting (求逆序数)
- POJ 1007.DNA Sorting
- poj 1007 DNA Sorting
- poj 1007 DNA Sorting(排序--快排)
- POJ 1007 && HDU 1379 DNA Sorting(水~)
- POJ 一 1007 DNA Sorting
- [POJ_1007] DNA Sorting
- 【POJ】1007 DNA Sorting
- POJ 1007 DNA Sorting
- POJ-1007 DNA Sorting
- poj 1007 DNA Sorting
- POJ 1007 - DNA Sorting
- poj 1007 DNA Sorting 求逆序数
- poj-1007-DNA Sorting