1. 有1、2、3、4个数字,能组成多少个互不相同且无重复数字的三位数?都是多少?
#include
int main()
{
printf("The whole numbers are as follows:>n");
int count = 0;
for (int i = 1; i <= 4; i++)
for (int j = 1; j <= 4; j++)
for (int k = 1; k <= 4; k++)
if (i != k && i != j&& k != j)
{
count++;
printf("%d ", i * 100 + j * 10 + k);/
10. 输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数。
#include
#include//isalpha()的头文件
int main()
{
int ch,alp=0,blk=0,num=0,oth=0;
while ((ch = getchar()) != EOF)
{
if (isalpha(ch))//如果是字母返回1
alp++;
//或(ch>='a'&&ch<='z')||(ch>='a'&&ch<='z')
else if (ch == ' ') blk++;
else if (ch >= '0'&&ch <= '9') num++;
else oth++;
}
printf("the number of alpha is %dn",alp);
printf("the number of blank space is %dn",blk);
printf("the number of number is %dn",num);
printf("the number of other is %dn",oth);
return 0;
}