# 算法竞赛入门经典（第二版）第2章习题

2.4.1 输出技巧
#include <stdio.h>

int
main()
{
int i, n;

scanf("%d", &n);
for (i = 1; i <= n; i++)
printf("%d\n", i);
return 0;
}

#include <stdio.h>

int
main()
{
int i;
int a, b, c;
for (i = 100; i != 1000; i++) {
a = i/100;
b = i/10%10;
c = i%10;
if (a*a*a + b*b*b + c*c*c == i)
printf("%d\n", i);
}
return 0;
}

#include <stdio.h>

int
main()
{
int a, b, c;
int i;

scanf("%d%d%d", &a, &b, &c);
for (i = 10; i != 100; i++) {
if (i%3 == a && i%5 == b && i%7 == c) {
printf("%d\n", i);
break;
}
}
if (i == 100)
return 0;
}

#include <stdio.h>

int
main(void)
{
int a, b, c;

scanf("%d%d%d", &a, &b, &c);
printf("%.*f\n", c, (double)a/b);
return 0;
}

#include <stdio.h>

int
main(void)
{
int i, j, k;
int i1, i2, i3;
int j1, j2, j3;
int k1, k2, k3;
int c, count;

for (i = 123; i <= 329; i++) {
j = i*2;
k = i*3;
i1 = i/100, i2 = i/10%10; i3 = i%10;
j1 = j/100, j2 = j/10%10; j3 = j%10;
k1 = k/100, k2 = k/10%10; k3 = k%10;
for (c = 1; c != 10; c++) {
count = 0;
if (c == i1)
count++;
if (c == i2)
count++;
if (c == i3)
count++;
if (c == j1)
count++;
if (c == j2)
count++;
if (c == j3)
count++;
if (c == k1)
count++;
if (c == k2)
count++;
if (c == k3)
count++;
if (count > 1)
break;
}
if (c == 10 && i2 != 0 && i3 != 0 && j2 != 0 && j3 != 0 && k2 != 0 && k3 != 0)
printf("%d %d %d\n", i, j, k);
}
return 0;
}