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

相关内容

热门资讯

曝光透视!哈糖大菠萝辅助器!玩... 曝光透视!哈糖大菠萝辅助器!玩家必看科普辅助软件(有挂秘笈)-哔哩哔哩1、让任何用户在无需哈糖大菠萝...
现就发布提示!hhpoker辅... 现就发布提示!hhpoker辅助软件(透视)都是存在有辅助平台(有挂教程)-哔哩哔哩1、hhpoke...
开挂透视!uupoker透视!... 开挂透视!uupoker透视!推荐一款辅助app(竟然有挂)-哔哩哔哩1、uupoker透视辅助软件...
透视好牌!pokemmo辅助器... 透视好牌!pokemmo辅助器手机版下载(透视)其实存在有辅助安装(了解有挂)-哔哩哔哩1、poke...
详细透视!哈糖大菠萝破解器!玩... 详细透视!哈糖大菠萝破解器!玩家攻略辅助工具(有挂规律)-哔哩哔哩1、下载好哈糖大菠萝破解器正确养号...
透视黑科技!wepoker轻量... 透视黑科技!wepoker轻量版有透视吗(透视)其实是有辅助安装(有挂分享)-哔哩哔哩wepoker...
推荐透视!hhpoker破解工... 推荐透视!hhpoker破解工具!揭秘一下辅助软件(有挂技巧)-哔哩哔哩1)hhpoker破解工具有...
做出回应!we-poker正规... 做出回应!we-poker正规吗(透视)竟然真的有辅助安装(真是有挂)-哔哩哔哩做出回应!we-po...
曝光透视!pokemmo辅助器... 曝光透视!pokemmo辅助器脚本下载!盘点十款辅助器(有挂详细)-哔哩哔哩pokemmo辅助器脚本...
透视好友!wejoker内置辅... 透视好友!wejoker内置辅助(透视)其实有辅助神器(揭秘有挂)-哔哩哔哩1、游戏颠覆性的策略玩法...