C语言日常练习Day13
创始人
2024-11-19 09:08:25
0

目录

一、有4个圆塔,圆心分别为(2,2)、(-2,2)、(-2,-2)、(2,-2),圆半径为1,这4个塔的高度为10cm,塔外无建筑物。现输入任一点的坐标,求该点的建筑高度(塔外的高度为0)

二、输入一行字符,分别统计出其中英文字母、空格、数字和其他字符的个数

三、求1!+2!+......+20!


一、有4个圆塔,圆心分别为(2,2)、(-2,2)、(-2,-2)、(2,-2),圆半径为1,这4个塔的高度为10cm,塔外无建筑物。现输入任一点的坐标,求该点的建筑高度(塔外的高度为0)

代码如下:

#include   int main() {     int h=10;     float x,y,d1,d2,d3,d4; 	float x1=2.0,y1=2.0; 	float x2=-2.0,y2=2.0; 	float x3=-2.0,y3=-2.0; 	float x4=2.0,y4=-2.0; 	printf("please input the point:"); 	scanf("%f,%f",&x,&y);  	d1=(x-x1)*(x-x1)+(y-y1)*(y-y1); 	d2=(x-x2)*(x-x2)+(y-y2)*(y-y2); 	d3=(x-x3)*(x-x3)+(y-y3)*(y-y3); 	d4=(x-x4)*(x-x4)+(y-y4)*(y-y4); 	if(d1>1&&d2>1&&d3>1&&d4>1) 	{ 		h=0; 	} 	 	printf("the height is :%d",h);     return 0; } 

二、输入一行字符,分别统计出其中英文字母、空格、数字和其他字符的个数

代码如下:

#include   int main() { 	int blank=0,english=0,number=0,other=0;     char ch;     while((ch=getchar())!='\n')     {     	if(ch==' ')     {     	blank++; 	} 	else if(ch>='a'&&ch<='z'||ch>='A'&&ch<='Z') 	{ 		english++; 	} 	else if(ch>='0'&&ch<='9') 	{ 		number++; 	} 	else 	{ 		other++; 	} 	} 	printf("英文字母有:%d\n",english); 	printf("空格有:%d\n",blank); 	printf("数字有:%d\n",number); 	printf("其他字符有:%d\n",other);     return 0; } 

三、求1!+2!+......+20!

代码如下:

#include  int main() { 	int i,sum=0,add=1; 	for(i=1;i<=20;i++) 	{ 		add*=i; 		sum+=add; 	} 	printf("%d",sum); 	return 0; } 

相关内容

热门资讯

wpk透视脚本!wpk德州局怎... wpk透视脚本!wpk德州局怎么透视,wepoker作弊辅助(详细辅助普及教程)1、不需要AI权限,...
透视苹果版!hhpoker万能... 透视苹果版!hhpoker万能辅助器,wepoker私人局怎么玩(详细辅助微扑克教程);最新版202...
透视辅助!wepoker透视脚... 透视辅助!wepoker透视脚本,wepoker辅助器下载,细节方法(好像真的有挂)1、wepoke...
透视科技“aapoker透视软... 透视科技“aapoker透视软件”一贯真的是有挂(辅助挂)详细辅助必备教程1、透视科技“aapoke...
德普之星透视辅助ios!pok... 德普之星透视辅助ios!pokemmo辅助官网,hhpoker辅助下载(详细辅助2025新版总结)是...
透视免费!aapoker有脚本... 透视免费!aapoker有脚本吗,德普辅助器辅助器怎么用(详细辅助教你教程)这是由厦门游乐互动科技有...
透视黑科技!hhpoker免费... 透视黑科技!hhpoker免费透视脚本,hh poker透视器下载,软件教程(真是有挂)1、hhpo...
透视了解“wpk透视脚本视频”... 透视了解“wpk透视脚本视频”切实真的有挂(辅助挂)详细辅助新2025教程;1、实时开挂更新:用户可...
wepoker透视脚本免费下载... 您好,智星德州辅助译码插件靠谱吗这款游戏可以开挂的,确实是有挂的,需要了解加微【136704302】...
透视新版!hhpoker透视脚... 透视新版!hhpoker透视脚本下载,hhpoker到底可以作弊吗,揭秘教程(切实有挂)1、操作简单...