22、
#include <stdio.h>
void main()
{
char i, j, k;
for (i = 'x'; i <= 'z'; i++)
{
for (j = 'x'; j <= 'z'; j++)
{
if(i!=j)
for (k = 'x'; k <= 'z'; k++)
{
if (i != k && j != k)
if (i != 'x'&&k != 'x'&&k != 'z')
printf("order is a--%c\tb--%c\tc--%c\n", i, j, k);
}
}
}
}
23、
#include <stdio.h>
void main()
{
int i, j, k;
for (i = 0; i <= 3; i++)
{
for (j = 0; j <= 2 - i; j++)
{
printf(" ");
}
for (k = 0; k <= 2 * i; k++)
{
printf("*");
}
printf("\n");
}
for (i = 0; i <= 2; i++)
{
for (j = 0; j <= i; j++)
{
printf(" ");
}
for (k = 0; k <= 4 - 2 * i; k++)
{
printf("*");
}
printf("\n");
}
}
24、
#include <stdio.h>
void main()
{
int n, t, num = 20;
float a = 2, b = 1, s = 0;
for (n = 1; n <= num; n++)
{
s = s + a / b;
t = a;
a = a + b;
b = t;
}
printf("sum is %9.6f\n", s);
}
25、
#include <stdio.h>
void main()
{
float n, s = 0, t = 1;
for (n = 1; n <= 20; n++)
{
t *= n;
s += t;
}
printf("1+2!+3!+...+20!=%f\n", s);
}