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

相关内容

热门资讯

透视挂透视!wepoker轻量... 透视挂透视!wepoker轻量版有透视吗,werplan有挂吗,要领教程(有挂详细)-哔哩哔哩1、w...
第十分钟科普!wepoker辅... 第十分钟科普!wepoker辅助工具(透视)都是真的有挂,解说技巧(确实有挂)-哔哩哔哩1、任何we...
透视规律!wepoker游戏安... 透视规律!wepoker游戏安装教程(透视)竟然真的是有挂,第三方教程(有挂开挂)-哔哩哔哩1、we...
透视透视!xpoker辅助神器... 透视透视!xpoker辅助神器,hhpoker德州有挂吗,讲义教程(有挂技巧)-哔哩哔哩hhpoke...
第4分钟曝光!aapoker辅... 第4分钟曝光!aapoker辅助软件合法吗(透视)竟然有挂,微扑克教程(发现有挂)-哔哩哔哩一、aa...
透视能赢!wepoker底牌透... 透视能赢!wepoker底牌透视脚本(透视)原来是真的挂,靠谱教程(有挂后台)-哔哩哔哩1、玩家可以...
辅助透视!aa poker透视... 辅助透视!aa poker透视软件,wpk模拟器是什么,妙招教程(今日头条)-哔哩哔哩1、wpk模拟...
第6分钟解谜!wepoker有... 第6分钟解谜!wepoker有透视功能吗(透视)真是有挂,大神讲解(有挂助手)-哔哩哔哩亲,关键说明...
透视计算!wejoker私人辅... 透视计算!wejoker私人辅助软件(透视)确实是真的挂,黑科技教程(有挂存在)-哔哩哔哩1、下载好...
透视智能ai!智星菠萝有挂吗,... 透视智能ai!智星菠萝有挂吗,wepoker辅助器安装包定制,法门教程(存在有挂)-哔哩哔哩1、we...