PEGASUS_NAMESPACE_END void CompareQualifiers( CIMRepository& r1, CIMRepository& r2, const CIMNamespaceName& namespaceName) { Array<CIMQualifierDecl> quals1 = r1.enumerateQualifiers(namespaceName); Array<CIMQualifierDecl> quals2 = r2.enumerateQualifiers(namespaceName); PEGASUS_TEST_ASSERT(quals1.size() == quals2.size()); BubbleSort(quals1); BubbleSort(quals2); for (Uint32 i = 0; i < quals2.size(); i++) { if (verbose) { cout << "testing qualifier " << namespaceName.getString() << "/"; cout << quals1[i].getName().getString() << "/ against /"; cout << quals2[i].getName().getString() << "/" << endl; } PEGASUS_TEST_ASSERT(quals1[i].identical(quals2[i])); } }
int main() { int num_array[NUM] = {0}; // Create our array int i = 0; // A counter for our for loops for(; i < NUM; i++) num_array[i] = rand()%1000; // Fill it with random numbers // Sort the array from least to greatest BubbleSort(num_array,NUM,true); // Print it out for(i = 0; i < NUM; i++) printf("%d ",num_array[i]); printf("\n\n"); // A couple blank lines // Sort the array from greast to least BubbleSort(num_array,NUM,false); // Print it out for(i = 0; i < NUM; i++) printf("%d ",num_array[i]); printf("\n\n"); // A couple blank lines return 0; // And we're done }
int Set_Union() { /* Get length of arrays */ int lenA = arr_size(SetA); int lenB = arr_size(SetB); /* Sort arrays */ BubbleSort(SetA, lenA); //Sort SetA BubbleSort(SetB, lenB); //Sort SetB /* Get the union */ int i = 0; int j = 0; int unionSize = 0; while(i < lenA && j < lenB) { if(SetA[i] < SetB[j]) { printf(" %d ", SetA[i++]); } else if(SetA[i] > SetB[j]) { printf(" %d ", SetB[j++]); } else { printf(" %d ", SetB[j++]); i++; } unionSize++; } /* Print remaining elements of larger array */ while(i < lenA) { printf(" %d ", SetA[i++]); unionSize++; } while(j < lenB) { printf(" %d ", SetB[j++]); unionSize++; } /* return the union size */ return unionSize; }
int main(int argc, const char * argv[]) { int a[N] = {12, 34, 21, 46, 89, 54, 26, 8, 6, 17}; int flag; while (1) { printf("输入1:从小到大排序\n,输入2:从大到小排列\n输入3:退出\n"); scanf("%d",&flag); switch (flag) { case 1: printf("排序前的数据为:"); Display(a, N); BubbleSort(a, N, Ascending); printf("从小到大排列后的数据为"); Display(a, N); break; case 2: printf("排序前的数据为:"); Display(a, N); BubbleSort(a, N, Descending); printf("从大到小排列后的数据为"); Display(a, N); break; case 3: return 0; break ; default: printf("输入数据不合法,请重新输入\n"); break; } } return 0; }
void Compare( const String& repositoryRoot1, const String& repositoryRoot2) { // // Create repositories: // CIMRepository r1(repositoryRoot1); CIMRepository r2(repositoryRoot2); // // Compare the namespaces. // Array<CIMNamespaceName> nameSpaces1 = r1.enumerateNameSpaces(); Array<CIMNamespaceName> nameSpaces2 = r2.enumerateNameSpaces(); BubbleSort(nameSpaces1); BubbleSort(nameSpaces2); PEGASUS_TEST_ASSERT(nameSpaces1 == nameSpaces2); // // Compare classes in each namespace: // for (Uint32 i = 0; i < nameSpaces1.size(); i++) { CompareQualifiers(r1, r2, nameSpaces1[i]); CompareClasses(r1, r2, nameSpaces1[i]); CompareInstances(r1, r2, nameSpaces1[i]); } }
/********************************************************************* 函数名称: FallWtProbabilityStatistics 功 能: 概率统计方法处理落差值 说 明: 采用概率统计处理方法处理落差,避免个别大误差造成误修正 入口参数: pfs_Adapt : 自适应参数结构体 fs32_RealFallWt : 实际得到的落差 出口参数: 返 回 值: 统计处理后的落差值 设 计: 丛海旭 时 间: 2015-08-19 修 改: 时 间: *********************************************************************/ s32 FallWtProbabilityStatistics(struct_adapt_t *pfs_Adapt, s32 fs32_RealFallWt) { s32 ls32_BestFall = 0; u32 i = 0; static s32 lss32_AddFallWTemp = 0; static s32 lss32_FallWRecord[SLFALLWT]; static s32 lss32_FallW_Pro[SLFALLWT]; if(pfs_Adapt->u32SP3Count>(SLFALLWT-1)) { for(i=0;i<(SLFALLWT-1);i++) { lss32_FallWRecord[i] = lss32_FallWRecord[i+1]; lss32_FallW_Pro[i] = lss32_FallWRecord[i]; } lss32_FallWRecord[SLFALLWT-1] = fs32_RealFallWt; lss32_FallW_Pro[SLFALLWT-1] = fs32_RealFallWt; BubbleSort(lss32_FallW_Pro, SLFALLWT); //冒泡排序 ls32_BestFall = (lss32_FallW_Pro[1]+lss32_FallW_Pro[2]*3+lss32_FallW_Pro[3]*5+lss32_FallW_Pro[4]*3+lss32_FallW_Pro[5])/13; //由于统计出落差值偏大 } else if(pfs_Adapt->u32SP3Count>=2) { lss32_FallWRecord[pfs_Adapt->u32SP3Count] = fs32_RealFallWt; for(i=0;i<=pfs_Adapt->u32SP3Count;i++) { lss32_FallW_Pro[i] = lss32_FallWRecord[i]; } BubbleSort(lss32_FallW_Pro, pfs_Adapt->u32SP3Count + 1); //冒泡排序 if(pfs_Adapt->u32SP3Count>=4) { ls32_BestFall = (lss32_FallW_Pro[1]+lss32_FallW_Pro[2]*2+lss32_FallW_Pro[3])/4; } else if(pfs_Adapt->u32SP3Count>=3) { ls32_BestFall = (lss32_FallW_Pro[1]+lss32_FallW_Pro[2])/2; } else if(pfs_Adapt->u32SP3Count>=2) { ls32_BestFall = lss32_FallW_Pro[1]; } pfs_Adapt->u32SP3Count++; } else { if(pfs_Adapt->u32SP3Count==0) //如果是刚启动,清零 { lss32_AddFallWTemp = 0; } lss32_FallWRecord[pfs_Adapt->u32SP3Count] = fs32_RealFallWt; pfs_Adapt->u32SP3Count++; lss32_AddFallWTemp += fs32_RealFallWt; ls32_BestFall = lss32_AddFallWTemp/pfs_Adapt->u32SP3Count; } return ls32_BestFall; }
/********************************************************************* 函数名称: SP2LinearKProbabilityStatistics 功 能: 概率统计方法处理小投线性拟合K值 说 明: 该函数一定放在FallWtProbabilityStatistics函数前面 因为FallWtProbabilityStatistics函数中有对pfs_Adapt->u32SP3Count++的操作 入口参数: pfs_Adapt=自适应参数结构体 fs32_KThisTime=实际得到的本次K值 出口参数: 返 回 值: 统计处理后的K值 设 计: 丛海旭 时 间: 2015-8-25 修 改: 时 间: *********************************************************************/ s32 SP2LinearKProbabilityStatistics(struct_adapt_t *pfs_Adapt, s32 fs32_KThisTime) { s32 ls32_Result = 0; u32 i = 0; static s32 lss32_AddFallWTemp = 0; static s32 lss32_KRecord[SLFALLWT]; static s32 lss32_K_Pro[SLFALLWT]; if(pfs_Adapt->u32SP3Count>(SLFALLWT-1)) { for(i=0;i<(SLFALLWT-1);i++) { lss32_KRecord[i] = lss32_KRecord[i+1]; lss32_K_Pro[i] = lss32_KRecord[i]; } lss32_KRecord[SLFALLWT-1] = fs32_KThisTime; lss32_K_Pro[SLFALLWT-1] = fs32_KThisTime; BubbleSort(lss32_K_Pro, SLFALLWT); //冒泡排序 ls32_Result = (lss32_K_Pro[1]+lss32_K_Pro[2]*3+lss32_K_Pro[3]*5+lss32_K_Pro[4]*3+lss32_K_Pro[5])/13; //由于统计出落差值偏大 } else if(pfs_Adapt->u32SP3Count>=2) { lss32_KRecord[pfs_Adapt->u32SP3Count] = fs32_KThisTime; for(i=0;i<=pfs_Adapt->u32SP3Count;i++) { lss32_K_Pro[i] = lss32_KRecord[i]; } BubbleSort(lss32_K_Pro, pfs_Adapt->u32SP3Count + 1); //冒泡排序 if(pfs_Adapt->u32SP3Count>=4) { ls32_Result = (lss32_K_Pro[1]+lss32_K_Pro[2]*2+lss32_K_Pro[3])/4; } else if(pfs_Adapt->u32SP3Count>=3) { ls32_Result = (lss32_K_Pro[1]+lss32_K_Pro[2])/2; } else if(pfs_Adapt->u32SP3Count>=2) { ls32_Result = lss32_K_Pro[1]; } // pfs_Adapt->u32SP3Count++; } else { if(pfs_Adapt->u32SP3Count==0) //如果是刚启动,清零 { lss32_AddFallWTemp = 0; } lss32_KRecord[pfs_Adapt->u32SP3Count] = fs32_KThisTime; // pfs_Adapt->u32SP3Count++; lss32_AddFallWTemp += fs32_KThisTime; ls32_Result = lss32_AddFallWTemp/(pfs_Adapt->u32SP3Count + 1); } return ls32_Result; }
void OutputShapesInCorrectOrder(std::vector<std::shared_ptr<CShape>> & figures) { BubbleSort(figures, true); std::cout << std::endl << "Shapes sorted by area:" << std::endl << std::endl; OutputShapes(figures); BubbleSort(figures, false); std::cout << std::endl << "Shapes sorted by perimeter:" << std::endl << std::endl; OutputShapes(figures); }
void CompareClasses( CIMRepository& r1, CIMRepository& r2, const CIMNamespaceName& namespaceName) { Array<CIMName> classNames1 = r1.enumerateClassNames(namespaceName); Array<CIMName> classNames2 = r2.enumerateClassNames(namespaceName); BubbleSort(classNames1); BubbleSort(classNames2); PEGASUS_TEST_ASSERT(classNames1 == classNames2); for (Uint32 i = 0; i < classNames1.size(); i++) { CIMClass class1 = r1.getClass(namespaceName, classNames1[i]); CIMClass class2 = r2.getClass(namespaceName, classNames2[i]); if (verbose) { cout << "testing class " << namespaceName.getString() << "/"; cout << classNames1[i].getString() << "..." << endl; } if (!class1.identical(class2)) { PutClass("file1", class1); PutClass("file2", class2); cout << "========================================================="; cout << "========================================================="; cout << endl; cout << "ERROR: not identical! - "; cout << "ERROR FOUND testing class: " << namespaceName.getString(); cout << "/"; cout << classNames1[i].getString(); cout << " .... differences follow:" << endl << endl; if (system("diff file1 file2") == -1) { cout << "Error: system(\"diff file1 file2\") failed." << endl; } if (verbose) { XmlWriter::printClassElement(class1, cout); XmlWriter::printClassElement(class2, cout); } failures++; } } }
void XSort(ElementType S[], long N, int X) { switch (X) { case 0: BubbleSort(S, N); break; case 1: InsertionSort(S, N); break; case 2: ShellSort(S, N); break; case 3: HeapSort(S, N); break; case 4: MergeSortByRecursiveImpl(S, N); break; case 5: MergeSortByNonRecursiveImpl(S, N); break; case 6: QuickSort(S, N); break; default: BubbleSort(S, N); break; } }
int main(){ Initialize(Array); BubbleSort(Array); return 0; }
void main() { int shuzu[SIZE],i; srand(time(NULL)); for(i=0;i<SIZE;i++) { shuzu[i]=rand()/1000 + 100; } printf("排序前的数组为:\n"); for(i=0;i<SIZE;i++) { printf("%d ",shuzu[i]); } printf("\n"); BubbleSort(shuzu,SIZE); printf("排序后的数组:\n"); for(i=0;i<SIZE;i++) { printf("%d ",shuzu[i]); } printf("\n"); }
/******************************************************************* QuickSort : Perform the quick sort operation. If size of array is : below the threshold, then use bubble sort, else : divide the job and insert one part into the task stack *******************************************************************/ QuickSort(register int i, register int j) { register int pivot, k; QSORT: /* pivot is index of the pivot element */ if(j-i+1 < BubbleThresh) { if(bubble) BubbleSort(i,j); else LocalQuickSort(i,j); return; } pivot = FindPivot(i,j); k = Partition(i,j,gMem->A[pivot]); if(k-i > j-k) { /* The lower half [i through (k-1)] contains more entries. */ /* Put the other half into the queue of unsorted subarrays */ /* and recurse on the other half. */ PushWork(k,j); j=k-1; goto QSORT; /* QuickSort(i, k-1); */ /* eliminating tail recursion */ } else { PushWork(i,k-1); i=k; goto QSORT; /* QuickSort(k,j); */ /* Eliminating tail recursion */ } }
int main(){ long ct_repeat=0; long ct_repeat_max=1; int ct_return=0; #ifdef XOPENME xopenme_init(1,2); #endif if (getenv("CT_REPEAT_MAIN")!=NULL) ct_repeat_max=atol(getenv("CT_REPEAT_MAIN")); #ifdef XOPENME xopenme_clock_start(0); #endif for (ct_repeat=0; ct_repeat<ct_repeat_max; ct_repeat++) { Initialize(Array); BubbleSort(Array); } #ifdef XOPENME xopenme_clock_end(0); xopenme_dump_state(); xopenme_finish(); #endif return 0; }
int main(void) { int x[20]={17,10,13,14,15,6,3,2,9,8,18,7,12,11,16,4,1,20,5,19}; FsOpenWindow(16,16,400,400,1); BubbleSort(20, x); return 0; }
int main(void){ int N,i,j,num = 0; char cards[CARDS][3]; char Bubble[CARDS][3]; char Selection[CARDS][3]; char check[NUMBER][SUIT+1] = {0}; char Bubblecheck[NUMBER][SUIT+1] = {0}; char Selectioncheck[NUMBER][SUIT+1] = {0}; scanf("%d" ,&N); for(i = 0;i < N;i++){ scanf("%s", cards[i]); } /*copy array*/ memcpy(Bubble,cards,sizeof cards); memcpy(Selection,cards,sizeof cards); Checker(cards,check,N); BubbleSort(Bubble,N); Checker(Bubble,Bubblecheck,N); StableChecker(Bubblecheck,check); SelectionSort(Selection,N); Checker(Selection,Selectioncheck,N); StableChecker(Selectioncheck,check); return 0; }
bool MReportDataAdapter::GetRelativelyLargeEvents(QDate &begin, QDate &end, EventInfoList &list, bool all) { if (!GetSeisEventInfo(begin, end, list)) { return false; } BubbleSort(list); if (!all) { // AppSettings setting = ConfigManager::GetInstance()->AppSetting(); MDataConfig* conf = MDataConfig::GetInstance(); // float reference_magnitude = settting.large_event_reference_magnitude(); // float reference_magnitude = setting.filter_relative_large_event_magnitude(); float reference_magnitude = conf->relatively_event_filter_magnitude(); for (int i = list.count() - 1; i >= 0; i--) { if (list.at(i)->magnitude < reference_magnitude) { list.removeAt(i); } } // int show_num = settting.large_event_show_num(); // int show_num = setting.filter_relative_large_event_display_num(); int show_num = conf->relatively_event_display_num(); list = list.mid(0, show_num); return true; } return true; }
int main_test(int init_factor) { Initialize(Array, init_factor); BubbleSort(Array); return 0; }
void main() { int **matrix; int col, row, i, j, ch; do { system("cls"); printf("Enter the size of a matrix:\n\tcol = "); scanf("%d", &col); printf("\trow = "); scanf("%d", &row); if (col > 0 && row > 0) { matrix = (int**) calloc(row, sizeof(int*)); for (i = 0; i < row; i++) matrix[i] = (int*) calloc(col, sizeof(int)); SetData(matrix, row, col); putchar('\n'); PrintMatrix(matrix, row, col); for (i = 0; i < col; i++) BubbleSort(matrix,row, i); Proverka(matrix, row, col); for (i = 1; i < row; i++) free(matrix[i]); free(matrix); } else printf("ERROR: Wrong input!!!"); printf("\n\nRepeat? (y/n)"); } while (tolower((ch = getch())) == 'y'); }
int main() { int pole1[10] = {7, 1, 2, 0, 8, 4, 5, 3, 9, 6}; int pole2[10] = {0, 3, 1, 8, 7, 2, 5, 4, 6, 9}; int pole3[10] = {2, 1, 3, 6, 9, 0, 4, 5, 7, 8}; printf("Původní pole1: "); VypisPole(pole1, 10); InsertSort(pole1, 10); printf("\nSetřízené pole1 (InsertSort): "); VypisPole(pole1, 10); printf("\nPůvodní pole2: "); VypisPole(pole2, 10); BubbleSort(pole2, 10); printf("\nSetřízené pole2 (BubbleSort): "); VypisPole(pole2, 10); printf("\nPůvodní pole3: "); VypisPole(pole3, 10); SelectSort(pole3, 10); printf("\nSetřízené pole3 (SelectSort): "); VypisPole(pole3, 10); return 0; }
void class14(){ // double a = 5.5; // double b = 6.6; // // cout<<"Sum of local a + b is "<<a+b<<endl; // cout<<"Sum of global a + b is "<<::a+::b<<endl; ///////////////////////////////////////////////////////// // char charArray[20]; // // // cout<<"Enter character string : "; // cin>>charArray; // convert(charArray); // cout<<charArray<<endl; //////////////////////////////////////////////////////// int Array1[SIZE]; int Array2[SIZE]; int Array3[SIZE*2]; //int number; //int *A1Pr; cout<<"Enter 5 number for array1 : "; for(int i=0;i<SIZE;i++){ cin>>Array1[i]; } cout<<"Enter 5 number for array2 : "; for(int i=0;i<SIZE;i++){ cin>>Array2[i]; } cout<<"----------Array 1------------"<<endl; BubbleSort(Array1); cout<<endl; cout<<"----------Array 2------------"<<endl; BubbleSort(Array2); cout<<endl; cout<<"----------Array 3------------"<<endl; marge(Array1, Array2, Array3); cout<<endl; }
void main(void) { int y[10] = {10,7,8,9,4, 2, 3, 6, 5,1}; BubbleSort(y,10); for (int i = 0; i < 10; i++) cout << y[i] << ' '; cout << endl; }
int main(int argc, char* argv[]) { std::vector<int> v = {-1,5,-9,3,-3,4,4,2,1}; Print(BubbleSort(v)); Print(InsertSort(v)); Print(SelectionSort(v)); std::cout << "--------------" << std::endl; return EXIT_SUCCESS; }
int main(){ int i,a[N]; printf("please enter 5 number,divide by \\n \n"); for(i=0;i<N;i++) scanf("%d",&a[i]); BubbleSort(a, N); printArray(a, N); getche(); }
int main(void) { int arr[] = { 5, 4, 12, 36, 1, 9, 11, 24, 100, 50 }; BubbleSort(arr, 10); PrintArray(arr, 10); return 0; }
main() { SSTable ST; int loc,key; int n; scanf("%d",&n); Creat_Seq(ST,n); BubbleSort(ST); }
void test_BubbleSort_given_1_20_14_13_11_should_return_1_11_13_14_20(void) { int array[] = {1, 20, 14, 13, 11}; BubbleSort(array, 5); TEST_ASSERT_EQUAL(1, array[0]); TEST_ASSERT_EQUAL(11, array[1]); TEST_ASSERT_EQUAL(13, array[2]); TEST_ASSERT_EQUAL(14, array[3]); TEST_ASSERT_EQUAL(20, array[4]); }
void TestBubbleSort() { int array[] = {2,5,6,9,1,3,4,7,8,0}; BubbleSort(array,sizeof(array)/sizeof(array[0])); for(int i = 0; i<sizeof(array)/sizeof(array[0]); i++) { cout<<array[i] <<" " ; } cout <<endl; }
int main() { int A[100], n, s, m, i; scanf("%d", &n); for (i = 0; i < n; i++) scanf("%d", &A[i]); BubbleSort(A, 0, n); printf("%d\n", num); return 0; }
enum SearchResult RunTest (int array[], int datasize, int key, int *count) { BubbleSort(array, datasize); int low = 0; int high = datasize-1; int query = BinarySearch(array, low, high, key, count); if (query == -1) return NOTFOUND; else return FOUND; }