-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtools.cpp
More file actions
46 lines (43 loc) · 769 Bytes
/
tools.cpp
File metadata and controls
46 lines (43 loc) · 769 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/********************************
*@file: tools.cpp
*@author: Hu Pan
*@date: 2015/09/12
*@version: 0.1
*@describe: coding工具函数
********************************/
#include <iostream>
#include <stack>
using namespace std;
template <typename T>
void my_swap(T var1, T var2)
{
if (*var1 != *var2)
{
*var1 ^= *var2;
*var2 ^= *var1;
*var1 ^= *var2;
}
}
template <typename T>
void display(T beg, T end)
{
while (beg != end)
{
cout << *beg++ ;
}
cout << endl;
}
void numToChar(char *src, int num, int &index)
{
stack<int> sta;
while (num)
{
sta.push(num % 10);
num /= 10;
}
while (sta.size())
{
src[index++] = sta.top() + '0';
sta.pop();
}
}