C++模板引用

template <typename T>
inline T max2(T a, T  b)
{
	return a < b ? a : b;
}
int _tmain(int argc, _TCHAR* argv[])
{
起始:
	clock_t start = clock();
	cout << max2(4.1, 5.1) << endl;

	clock_t stop = clock();
	printf_s("耗时:%lf\n", (double)(stop - start) / CLOCKS_PER_SEC);
		system("pause");
		//system("cls");
		goto 起始;
		//return 0;
}
struct 邻和质数类{ int 数1; int 数2; };
邻和质数类* 邻对质数源(邻和质数类 对质数[])
{
	int 质数组[] = { 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37 }, 
		序 = 0, 头 = 0, 尾 = 10, 数1 = 1, 数2 = 2;
	do
	{//以奇数起与偶数结合,则所有奇偶数都包含了,因为一个奇数对多个偶数=多个偶数对一个奇数.
		do
		{
			if (质数组[头] == 数1 + 数2 || 质数组[尾] == 数1 + 数2)
			{
				对质数[序++] = { 数1, 数2 };
				break;
			}
		} while (++头 <= --尾);
		数2 += 2; 头 = 0; 尾 = 10;
		if (数2 > 20){ 数2 = 2; 数1 += 2; }
	} while (数1 < 20);
	return 对质数;
}
list<int> 质数数据源()
{
	int 质数组[] = { 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37 }, 序 = 0, 头 = 0, 尾 = 10, 数1 = 1, 数2 = 2;
	list<int> 动态;
	do
	{//以奇数起与偶数结合,则所有奇偶数都包含了,因为一个奇数对多个偶数=多个偶数对一个奇数.
		do
		{
			if (质数组[头] == 数1 + 数2 || 质数组[尾] == 数1 + 数2)
			{
				动态.push_back(数1);
				动态.push_back(数2);
				break;
			}
		} while (++头 <= --尾);
		数2 += 2; 头 = 0; 尾 = 10;
		if (数2 > 20){ 数2 = 2; 数1 += 2; }
	} while (数1 < 20);
	return 动态;
}
template <class T>
void sort(T s[], int n)
{
	T t = 0;
	for (int j = 0; j < n; j++)
		for (int i = j + 1; i < n; i++)
			if (s[j] > s[i])
			{
				t = s[j];
				s[j] = s[i];
				s[i] = t;
			}
}
template <class 形参>
形参 相加(形参 a, 形参 b){ return a + b; }
template <class T>
T 最小(T A, T B){ return A < B ? A : B; }
struct 学生个人信息类{ string 学号; string 姓名; int 年龄; string 性别; string 住址; int 电话; };
class total
{
public:char a[26];
	   char s[200];
	   int i;
	   void enter()
	   {
		   
	   }
	   void cale();
	   void puts();
};
void total::cale()
{
	for (i = 0; s[i] != '\0'; i++)
	{
		if (s[i] >= 'A'&&s[i] <= 'Z') a[s[i] - 'A']++;
		if (s[i] >= 'a'&&s[i] <= 'z') a[s[i] - 'a']++;
	}
}
void total::puts()
{
	for (i = 0; i<26; i++) if (a[i]) printf_s("%c %d\n", i + 'a', a[i]);//
}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值