1
2 void FileHandle(string name,string outfile)
3 {
4 ifstream in(name.c_str());
5 ofstream out(outfile.c_str());
6
7 if(in) {
8
9 out << in.rdbuf();
10
11 }
12 in.close();
13 out.close();
14 }
2 void FileHandle(string name,string outfile)
3 {
4 ifstream in(name.c_str());
5 ofstream out(outfile.c_str());
6
7 if(in) {
8
9 out << in.rdbuf();
10
11 }
12 in.close();
13 out.close();
14 }
------------------------------------
时间
#include<time.h>
time_t t = time(NULL);
cout << ctime(&t);
// Thu Oct 07 12:16:08 2010
-------------------------------------
字符串
#include<string>
string str;
assign(string);
append();
c_str();
find_first_of();
substr(int start,int len);
--------------------------------------
目录操作
#include<io.h>
_finddata_t data;
long handle = _findfirst(“”,&data);
-----------------------------------------
打印矩阵
n = 4
1 4 5 16
2 3 6 15
9 8 7 14
10 11 12 13
1 #include <iostream>
2 using namespace std;
3
4 int main()
5 {
6 int n;
7 cin >> n;
8 int **d;
9 d = new int * [n];
10 for (int i=0;i<n;i++) {
11 d[i] = new int[n];
12 }
13 int count = 1;
14 for (int i = 1;i<=n;i++) {
15 if (i%2 == 1) {
16 for (int j=0;j<i;j++) {
17 d[i-1][j] = count++;
18 }
19 for (int j=i-2;j>=0;j--) {
20 d[j][i-1] = count++;
21 }
22 }
23 else {
24 for (int j=0;j<i;j++) {
25 d[j][i-1] = count++;
26 }
27 for (int j=i-2;j>=0;j--) {
28 d[i-1][j] = count++;
29 }
30 }
31 }
32
33 for (int i=0;i<n;i++) {
34 for (int j=0;j<n;j++) {
35 cout << d[i][j] << "\t";
36 }
37 cout << endl;
38 }
39
40 cin >> n;
41 return 0;
42 }
2 using namespace std;
3
4 int main()
5 {
6 int n;
7 cin >> n;
8 int **d;
9 d = new int * [n];
10 for (int i=0;i<n;i++) {
11 d[i] = new int[n];
12 }
13 int count = 1;
14 for (int i = 1;i<=n;i++) {
15 if (i%2 == 1) {
16 for (int j=0;j<i;j++) {
17 d[i-1][j] = count++;
18 }
19 for (int j=i-2;j>=0;j--) {
20 d[j][i-1] = count++;
21 }
22 }
23 else {
24 for (int j=0;j<i;j++) {
25 d[j][i-1] = count++;
26 }
27 for (int j=i-2;j>=0;j--) {
28 d[i-1][j] = count++;
29 }
30 }
31 }
32
33 for (int i=0;i<n;i++) {
34 for (int j=0;j<n;j++) {
35 cout << d[i][j] << "\t";
36 }
37 cout << endl;
38 }
39
40 cin >> n;
41 return 0;
42 }