您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ BubbleSort函数代码示例

51自学网 2021-06-01 19:55:49
  C++
这篇教程C++ BubbleSort函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中BubbleSort函数的典型用法代码示例。如果您正苦于以下问题:C++ BubbleSort函数的具体用法?C++ BubbleSort怎么用?C++ BubbleSort使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了BubbleSort函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: CompareQualifiers

PEGASUS_NAMESPACE_ENDvoid 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]));    }}
开发者ID:brunolauze,项目名称:pegasus,代码行数:26,


示例2: main

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}
开发者ID:twinklingstar20,项目名称:Programming-Tutorials,代码行数:28,


示例3: Set_Union

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;} 
开发者ID:cobookman,项目名称:HW-ECE2035,代码行数:30,


示例4: main

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;}
开发者ID:markmamian,项目名称:DataSt,代码行数:31,


示例5: Compare

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]);    }}
开发者ID:brunolauze,项目名称:pegasus,代码行数:32,


示例6: FallWtProbabilityStatistics

/*********************************************************************函数名称: 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;   }
开发者ID:DharmaPatil,项目名称:-,代码行数:69,


示例7: SP2LinearKProbabilityStatistics

/*********************************************************************函数名称: 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;}
开发者ID:DharmaPatil,项目名称:-,代码行数:69,


示例8: OutputShapesInCorrectOrder

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);}
开发者ID:dlxgit,项目名称:OOP,代码行数:10,


示例9: CompareClasses

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++;    }    }}
开发者ID:brunolauze,项目名称:pegasus,代码行数:55,


示例10: XSort

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;    }}
开发者ID:LuoYY,项目名称:DataStructures,代码行数:14,


示例11: main

int main(){   Initialize(Array);   BubbleSort(Array);   return 0;}
开发者ID:Paschalis,项目名称:adapt16_benchmarks,代码行数:7,


示例12: main

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");}
开发者ID:cswanghan,项目名称:code,代码行数:29,


示例13: QuickSort

/*******************************************************************  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 */    }}
开发者ID:vag1830,项目名称:MultiprocSimulationLabs,代码行数:34,


示例14: main

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;}
开发者ID:ctuning,项目名称:reproduce-adapt16,代码行数:29,


示例15: main

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;}
开发者ID:hewolf,项目名称:Engineering-Computation,代码行数:7,


示例16: main

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;}
开发者ID:lp6m,项目名称:AIZU_ONLINE_JUDGE,代码行数:32,


示例17: BubbleSort

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;}
开发者ID:liye0005,项目名称:QT_POJ,代码行数:33,


示例18: main_test

intmain_test(int init_factor){  Initialize(Array, init_factor);  BubbleSort(Array);  return 0;}
开发者ID:t-crest,项目名称:patmos-benchmarks,代码行数:7,


示例19: main

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');}
开发者ID:Raumo0,项目名称:Labs,代码行数:32,


示例20: main

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
C++ Buffer函数代码示例
C++ Bterm函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。