-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path12-22.c
More file actions
117 lines (94 loc) · 1.38 KB
/
12-22.c
File metadata and controls
117 lines (94 loc) · 1.38 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<math.h>
//int is_prime(int n)
//{
// int j = 1;
// for (j = 2; j <=sqrt(n); j++)
// {
// if (n % j ==0)
// {
// return 0;
// }
// }
// return 1;
//}
//
//int main()
//{
// int i = 0;
// int count = 0;
// for (i = 101; i <= 200; i += 2)
// {
// if (is_prime(i))
// {
// printf(" %d", i);
// count++;
// }
// }
// printf("\ncount = %d\n", count);
// return 0;
//
//}
//void runnian(i)
//{
//
// if ((i % 400 == 0) || (i % 4 == 0 && i % 100 != 0))
// {
// printf("该年份为闰年.");
// }
// else
// {
// printf("该年份不是闰年");
// }
//}
//
//
//int main()
//{
// int a = 0;
// puts("请输入年份:");
// scanf("%d", &a);
// runnian(a);
// return 0;
//}
//int binary_search(int arr[], int k, int sz)
//{
// int left = 0;
// int right = sz - 1;
// while (left <= right)
// {
// int mid = left + (right - left) / 2; //不用 (left+right)/2是为了防止溢出
// if (arr[mid] < k)
// {
// left = mid + 1;
// }
// else if (arr[mid] > k)
// {
// right = mid - 1;
// }
// else
// {
// return mid;
// }
// }
// return -1; // 找不到
//
//}
//
//int main()
//{
// int arr[] = { 1,2,3,4,5,6,7,8,9,10 };
// int k = 7;
// int sz = sizeof(arr) / sizeof(arr[0]);
// int ret = binary_search(arr,k,sz);
// if (ret == -1)
// {
// printf("找不到\n");
// }
// else
// {
// printf("找到了,下标是:%d\n", ret);
// }
// return 0;
//}