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

相关内容

热门资讯

透视辅助!xpoker怎么辅助... 您好,xpoker怎么辅助这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302】很...
透视神器!wepoker提高好... 透视神器!wepoker提高好牌率,wepoker好友局透视,妙计教程(有挂辅助)-哔哩哔哩1、we...
第一分钟解迷!wepoker怎... 第一分钟解迷!wepoker怎么设置透视(透视)真是有挂,必赢教程(有挂方略)-哔哩哔哩1、让任何用...
透视脚本!hhpoker辅助挂... 透视脚本!hhpoker辅助挂下载(透视)其实真的是有挂,必备教程(有挂插件挂)-哔哩哔哩1、任何h...
透视科技!wepoker安装教... 透视科技!wepoker安装教程,wepoker辅助真的假的,讲义教程(有挂技巧)-哔哩哔哩1、这是...
三分钟揭幕!竞技联盟辅助(透视... 三分钟揭幕!竞技联盟辅助(透视)真是是真的挂,扑克教程(有挂方法)-哔哩哔哩1、在竞技联盟辅助ai机...
透视总结!红龙poker辅助工... 透视总结!红龙poker辅助工具(透视)一贯是真的挂,扑克教程(有挂机制)-哔哩哔哩1、红龙poke...
透视挂!hhpoker辅助靠谱... 透视挂!hhpoker辅助靠谱吗,pokerworld破解版下载,操作教程(真的有挂)-哔哩哔哩1、...
第6分钟曝光!hhpoker有... 第6分钟曝光!hhpoker有没有辅助辅助(透视)一直有挂,必备教程(有挂技巧)-哔哩哔哩1、hhp...
透视脚本!约局吧德州可以透视吗... 透视脚本!约局吧德州可以透视吗(透视)本来有挂,透牌教程(有挂总结)-哔哩哔哩所有人都在同一条线上,...