The study for the template

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了The study for the template相关的知识,希望对你有一定的参考价值。

/*冒泡排序.cpp---study for the template*/

#include<iostream>

using namespace std;

template <typename ElementType>//关键

/*ElementType max(ElementType a, ElementType b){

return a > b ? a : b;

}*/

void SortBuble(ElementType* a,int size){//from little to big;

int work = 0;

ElementType temp;

for (int i = 0; i < size; i++){

for (int j = size - 1; j>=i; j--){

if (a[j] < a[j - 1]){

temp = a[j];

a[j] = a[j-1];

a[j-1] = temp;

work = 1;

}

}

if (work == 0) break;

}

}

int main(){

cout.setf(ios_base::showpoint);

cout.precision(3);

/*cout << "max=" << max(5.0, 6.0)<<endl;

cout << "max=" << max(5, 6) << endl;

cout << "max=" << max(‘a‘, ‘b‘) << endl;*/

int a = 3;//不用中间量交换两值

int b = 4;

cout << "a=" << a << "b=" << b << endl;

a = a - b;

b = a + b;

a = b - a;

cout << "a=" << a << "b=" << b << endl;

double s[10] = { 2.2, 3.5, 5.2, 6.25, 4.2, 8, 7.7, 2.8, 1, 15 };

SortBuble(s, 10);

for (int i = 0; i < 10; i++){ cout << s[i] << endl; }

system("pause");

return 0;

}


以上是关于The study for the template的主要内容,如果未能解决你的问题,请参考以下文章

Cheetah Software Study Notes 2----the configuration pyqt

Study of the JavaServer Faces Lifecycle

C study C in the C.

study06:关于maven仓库的问题 was cached in the local repository,

文献阅读——Understanding the Role of Mixup in Knowledge Distillation: An Empirical Study

论文阅读 | COMPRESSING BERT: STUDYING THE EFFECTS OF WEIGHT PRUNING ON TRANSFER LEARNING