栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

C语言经典50题(1-10)

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

C语言经典50题(1-10)

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;
}

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/511779.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号