1 #define _CRT_SECURE_NO_WARNINGS
2
3 #include <stdlib.h>
4 #include <stdio.h>
5 #include <Windows.h>
6 #include <process.h>
7 #include <time.h>
8
9 void title(void *p)
10 {
11 char title[100];
12 int i = 0;
13
14 while (1)
15 {
16 sprintf(title, "title 程序已经运行了%d秒", i);
17 system(title);
18 i++;
19 Sleep(1000);
20 }
21
22 }
23
24 void color_change(void *p)
25 {
26 char color[100];
27 srand(time(0));
28 while (1)
29 {
30 int num1 = rand() % 16;
31 int num2 = rand() % 16;
32 sprintf(color, "color %x%x", num1, num2);
33 system(color);
34 Sleep(1000);
35 }
36 }
37
38 void main()
39 {
40 _beginthread(title, 0, NULL);
41 _beginthread(color_change, 0, NULL);
42
43
44 system("pause");
45 }