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
#include <stdio.h>
#include <math.h>
int ncr(int n, int r) {
int ncr = 1;
for (int i = 0; i < r; i++) {
ncr *= n - i;
ncr /= i + 1;
}
return ncr;
}
void hit_c(char c, int n) {
while (n--)
printf("%c", c);
}
void main() {
printf("coin num(1-16)? ");
int n;
scanf("%d", &n);
if (n < 1 || n > 16) return;
double p = pow(2, -n);
for (int r = 0; r < n + 1; r++) {
printf("%2d: ", r);
hit_c('*', ncr(n, r) * p * 2 * 70 + 0.5);
printf("\n");
}
}