void clearBoolMatrix(bool *a, int size)
{
int i;
for (i = 0; i < size; i++)
{
a[i] = false;
}
}
int main(int argc, char *argv[])
{
bool a[101];
bool sum[200];
int index_a;
int i, j;
bool result;
index_a = 1;
clearBoolMatrix(a, 101);
clearBoolMatrix(sum, 200);
for (i = 1; i < 100; i++)
{
result = true;
for (j = 1; j < i; j++)
{
if (a[j])
{
int s = j + i;
if (sum[s])
{
result = false;
break;
}
}
}
if (result)
{
for (j = 1; j < i; j++)
{
if (a[j])
{
int s = j + i;
sum[s] = true;
}
}
a[i] = true;
printf(" -- %d\n", i);
}
}
system("pause");
return 0;
} |