Error[8]: Undefined offset: 1, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

1.利用数组,与一个变量word实现空格判断

word=1代表空格,word=0没有空格

main()
{
	char s[20];
	int word = 1, i,sum=0;
	printf("请输入文章(敲回车确定)");
	gets(s);
	for (i = 0; s[i] != '[+++]'; i++)
	{
		if (s[i] == ' ')
			word = 1;
		else if (word == 1)
		      {
			 s[i]=s[i]-32;
			word = 0;
			sum++;
		       }
	}
	printf("首字母大写:\n");
	puts(s);
	printf("共有%d个", sum);
}

 

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
18.C语言统计英文文章个数和大写首字母_C_内存溢出

18.C语言统计英文文章个数和大写首字母

18.C语言统计英文文章个数和大写首字母,第1张

1.利用数组,与一个变量word实现空格判断

word=1代表空格,word=0没有空格

main()
{
	char s[20];
	int word = 1, i,sum=0;
	printf("请输入文章(敲回车确定)");
	gets(s);
	for (i = 0; s[i] != ''; i++)
	{
		if (s[i] == ' ')
			word = 1;
		else if (word == 1)
		      {
			 s[i]=s[i]-32;
			word = 0;
			sum++;
		       }
	}
	printf("首字母大写:\n");
	puts(s);
	printf("共有%d个", sum);
}

 

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/langs/3002951.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-09-27
下一篇 2022-09-27

发表评论

登录后才能评论

评论列表(0条)

保存