(Sorting algorithm for programming 7.3.11) POJ 1007 DNA Sorting (using bubbling sorting algorithm to calculate counter -order pair)

2023-03-18  

/* 
  * Poj_1007.cpp 
  * 
  * Created on: November 4, 2013 
  * Author: administrator 
  */ 

 #include <iOSTREAM> 
 #include <cstdio> 
 #include <string> 
 #include <cstring> 
 #include <algorithm> 

 using namespace std; 

 const into maxn = 105; 
 struct dNA { 
 String Str; 
 int Num; 
 } dnas [maxn]; 

 BOOL CMP (Const DNA & A, Const DNA & B) {{ 
 Return a.num <b.num; 
 } 

 int Main () { 
 int n, m; 

 While (Scanf ("%D%D", & N, & M)! = EOF) { 
 int i; 
 for (i = 0; i <m; ++ i) { 
 cin >> dnas [i] .str; 
 dnas [i] .num = 0; 
 int j, k; 
 for (k = 0; k <n; ++ k) {// bubbling sorting 
 for (j = k +1; j <n; ++ j) { 
 if (dnas [i] .str [k]> dnas [i] .str [j]) { 
 dnas [i] .num ++; // Reverse order pair +1 
 } 
 } 
 } 

 } 

 sort (DNAS, DNAS+M, CMP); 

 for (i = 0; i <m; ++ i) { 
 core << dnas [i] .str << Endl; 
 } 
 } 

 Return 0; 
 }

source

Random Posts

Ubuntu16.04 Install NVIDIA Drive GCC4.8ACONDA2CUDA9.0CUDNNNNNNNNNNCAFFEPYTENSORFLOWKERAS tutorial tutorial

Luo Gu P1020 missile intercepting [LIS greed+two points]

Python uses MITMPROXY Middle People Agent Fool Version Memoryand

Drag -Drag progress bar display progress

Android tinker hot update SampleDemo access