poj_1007 排序水题
2015-01-27 11:34
232 查看
code:
<span style="font-size:18px;">#include <iostream> #include <fstream> using namespace std; void quick_sort(char s[][51],int sort[],int left,int right) { if (left < right) { int i = left, j = right, x = sort[i]; char temp[51]; strcpy(temp,s[i]); while (i < j) { while (i<j&&sort[j]>x) j--; if (i < j) { // i <-> j strcpy(s[i], s[j]); sort[i++] = sort[j]; } while (i<j&&sort[i]<x) i++; if (i < j) { // i <-> j strcpy(s[j],s[i]); sort[j--] = sort[i]; } } sort[i] = x; strcpy(s[i], temp); quick_sort(s, sort, left, i-1); quick_sort(s, sort, i+1, right); } } int main() { fstream in("input.txt"); int n, m; char s[100][51]; int sort[100]; cin >> n >> m; memset(sort,0,sizeof(sort)); for (int i = 0; i < m; i++) { cin >> s[i]; } for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { for (int k = j + 1; k < n; k++) { if (s[i][j]>s[i][k]) sort[i]++; } } } //quick_sort quick_sort(s,sort,0,m-1); for (int i = 0; i < m; i++) cout << s[i] << endl; //system("pause"); return 0; } </span>
相关文章推荐
- POJ 1007 DNA排序求逆序数
- POJ 3664 排序,水题
- POJ 1007(无序度 排序) 解题报告
- POJ 1007 排序
- POJ 3312 Mahershalalhashbaz, Nebuchadnezzar, and Billy Bob Benjamin Go to the Regionals (排序水题)
- POJ1007 关于STL排序方法 动态数组的创建 和向量的使用
- poj 1007 DNA Sorting 【对逆序数进行sort排序】
- POJ 题目1007 DNA Sorting (水题 排序)
- poj 1007 DNA Sorting(排序--快排)
- POJ 1002 UVA 755 487--3279 电话排序 简单但不容易的水题
- POJ 2007 Scrambled Polygon 凸包加排序 水题一道
- POJ 1007(无序度 排序) 解题报告
- DNA Sorting - POJ 1007 排序
- poj 2388 排序的水题
- poj 1007 纯水题 排序
- POJ 1007 DNA 排序
- POJ 1007 DNA 排序
- poj 1007 DNA Sorting 【水题】
- poj 2291/3637 水题排序
- POJ 1007 DNA Sorting(水题) 逆…