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软件辅助程序(透视)开挂脚本软件(哔哩哔哩)1、游戏颠覆性的策略玩法,独创攻...
透视绝活!wepoker养号规... 透视绝活!wepoker养号规律(透视)开挂脚本辅助器(哔哩哔哩)1、操作简单,无需wepoker养...
透视步骤!hh poker透视... 透视步骤!hh poker透视器下载(透视)开挂透视app(哔哩哔哩)1、首先打开hh poker透...
透视演示!we poker辅助... 透视演示!we poker辅助器v3.3(透视)开挂脚本神器(哔哩哔哩)进入游戏-大厅左侧-新手福利...
透视攻略!云扑克有透视吗(透视... 透视攻略!云扑克有透视吗(透视)开挂脚本修改器(哔哩哔哩)1、下载好云扑克有透视吗正确养号方法之后点...
透视学习!aapoker安装包... 透视学习!aapoker安装包怎么使用(透视)开挂脚本下载(哔哩哔哩);1、aapoker安装包怎么...
透视演示!we-poker辅助... 透视演示!we-poker辅助器(透视)开挂脚本辅助器(哔哩哔哩)1.we-poker辅助器 选牌创...
透视总结!德州真人透视脚本(透... 透视总结!德州真人透视脚本(透视)开挂透视辅助器(哔哩哔哩)1、德州真人透视脚本模拟器是什么优化,德...
透视方针!wpk免费辅助(透视... 透视方针!wpk免费辅助(透视)开挂透视工具(哔哩哔哩)1、游戏颠覆性的策略玩法,独创攻略技巧玩法,...
透视技法!hhpoker买挂(... 透视技法!hhpoker买挂(透视)开挂脚本app(哔哩哔哩)1、进入游戏-大厅左侧-新手福利-激活...